Package edu.mit.csail.sdg.alloy4

Examples of edu.mit.csail.sdg.alloy4.ErrorFatal


    /** Add a new field 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.
     * <br> (If the field was already added by a previous call to addField(), then this call will return immediately without altering what it is associated with)
     */
    void addField(Field f, Expression expr) throws ErrorFatal {
       if (solved) throw new ErrorFatal("Cannot add an additional field since solve() has completed.");
       if (expr.arity()!=f.type().arity()) throw new ErrorFatal("Field "+f+" must be associated with an "+f.type().arity()+"-ary relational value.");
       if (a2k.containsKey(f)) return;
       a2k.put(f, expr);
    }
View Full Code Here


    /** 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;
    }
View Full Code Here

             TupleSet right = query(findUpper, b.right(), false);
             left.addAll(right);
             return left;
          }
       }
       throw new ErrorFatal("Unknown expression encountered during bounds computation: "+expr);
    }
View Full Code Here

       throw new ErrorFatal("Unknown expression encountered during bounds computation: "+expr);
    }

    /** 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 {
View Full Code Here

           if (!expr.errors.isEmpty()) throw expr.errors.pick();
           Object result = TranslateAlloyToKodkod.alloy2kodkod(this, expr);
           if (result instanceof IntExpression) return eval.evaluate((IntExpression)result);
           if (result instanceof Formula) return eval.evaluate((Formula)result);
           if (result instanceof Expression) return new A4TupleSet(eval.evaluate((Expression)result), this);
           throw new ErrorFatal("Unknown internal error encountered in the evaluator.");
        } catch(CapacityExceededException ex) {
           throw TranslateAlloyToKodkod.rethrow(ex);
        }
    }
View Full Code Here

    /** Maps a Kodkod formula to an Alloy Expr or Alloy Pos (or null if no such mapping) */
    Object k2pos(Node formula) { return k2pos.get(formula); }

    /** 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); }
View Full Code Here

        return formula;
    }

    /** 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); }
View Full Code Here

    //===================================================================================================//

    /** Associates the Kodkod relation to a particular Alloy Type (if it is not already associated with something) */
    void kr2type(Relation relation, Type newType) throws Err {
       if (solved) throw new ErrorFatal("Cannot alter the k->type mapping since solve() has completed.");
       if (!rel2type.containsKey(relation)) rel2type.put(relation, newType);
    }
View Full Code Here

       if (!rel2type.containsKey(relation)) rel2type.put(relation, newType);
    }

    /** Remove all mapping from Kodkod relation to Alloy Type. */
    void kr2typeCLEAR() throws Err {
       if (solved) throw new ErrorFatal("Cannot clear the k->type mapping since solve() has completed.");
       rel2type.clear();
    }
View Full Code Here

       return cachedPAIR;
    }

    /** Associates the Kodkod variable to a particular Alloy Type and Alloy Pos (if it is not already associated with something) */
    void kv2typepos(Variable var, Type type, Pos pos) throws Err {
       if (solved) throw new ErrorFatal("Cannot alter the k->type mapping since solve() has completed.");
       if (type==null) type=Type.EMPTY;
       if (pos==null) pos=Pos.UNKNOWN;
       if (!decl2type.containsKey(var)) decl2type.put(var, new Pair<Type,Pos>(type, pos));
    }
View Full Code Here

TOP

Related Classes of edu.mit.csail.sdg.alloy4.ErrorFatal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.