Package kodkod.instance

Examples of kodkod.instance.Bounds


     */
    private Solution trivialSolution(TrivialFormulaException tfe) {
      final Statistics stats = new Statistics(0, 0, 0, translTime, 0);
      if (tfe.value().booleanValue()) {
        trivial++;
        final Bounds translBounds = tfe.bounds();
        final Instance trivialInstance = padInstance(toInstance(translBounds), bounds);
        final Solution sol = Solution.triviallySatisfiable(stats, trivialInstance);
       
        final List<Formula> changes = new LinkedList<Formula>();
               
        for(Map.Entry<Relation, TupleSet> entry: trivialInstance.relationTuples().entrySet()) {
          final Relation r = entry.getKey();
         
          if (!translBounds.relations().contains(r)) {
            translBounds.bound(r, bounds.lowerBound(r), bounds.upperBound(r));
          }
         
          if (translBounds.lowerBound(r)!=translBounds.upperBound(r)) { // r may change
            if (entry.getValue().isEmpty()) {
              changes.add(r.some());
            } else {
              final Relation rmodel = Relation.nary(r.name()+"_"+trivial, r.arity());
              translBounds.boundExactly(rmodel, entry.getValue())
              changes.add(r.eq(rmodel).not());
            }
          }
        }
       
View Full Code Here


        if (bitwidth < 1)   throw new ErrorSyntax("Cannot specify a bitwidth less than 1");
        if (bitwidth > 30throw new ErrorSyntax("Cannot specify a bitwidth greater than 30");
        if (maxseq < 0)     throw new ErrorSyntax("The maximum sequence length cannot be negative.");
        if (maxseq > max()) throw new ErrorSyntax("With integer bitwidth of "+bitwidth+", you cannot have sequence length longer than "+max());
        kAtoms = ConstList.make(atoms);
        bounds = new Bounds(new Universe(kAtoms));
        factory = bounds.universe().factory();
        TupleSet sigintBounds = factory.noneOf(1);
        TupleSet seqidxBounds = factory.noneOf(1);
        TupleSet stringBounds = factory.noneOf(1);
        final TupleSet next = factory.noneOf(2);
View Full Code Here

    /** This tries a particular solution against the formula. */
    private static Solution trial (A4Reporter rep, TupleFactory fac, Solver solver, Iterable<Sig> sigs, Formula f, A4Solution frame, Object[] t) {
       try {
          frame.kr2typeCLEAR();
          Bounds b = null;
          TupleSet ts = null;
          for(int i=1; i<t.length; i++) {
             Object x=t[i];
             if (x==null) return null;
             if (x instanceof String && ((String)x).length()>0) { // This means it's a unary Tuple containing the given atom
                Tuple xx = fac.tuple((String)x);
                if (ts==null) ts=fac.noneOf(1);
                ts.add(xx);
                continue;
             }
             if (x instanceof Tuple) { // This means it's a Tuple
                Tuple xx=(Tuple)x;
                if (ts==null) ts=fac.noneOf(xx.arity());
                ts.add(xx);
                continue;
             }
             if (x instanceof String) { // The empty string means the sig name follows here
                i++;
                if (i>=t.length-1 || !(t[i] instanceof String) || !(t[i+1] instanceof String)) return null;
                String sigName = (String)(t[i]);
                i++;
                String fieldName = (String)(t[i]);
                Sig first = hasSig(sigs,sigName);
                if (first==null) return null;
                Expression expr = null;
                if (fieldName.length()==0) {
                    expr=frame.a2k(first);
                } else {
                    for(Field field:first.getFields()) if (field.label.equals(fieldName)) {
                        expr=frame.a2k(field);
                        while(expr instanceof BinaryExpression) expr=((BinaryExpression)expr).right();
                        break;
                    }
                }
                if (!(expr instanceof Relation)) return null;
                if (b==null) b = frame.getBounds(); // We delay the expansive Bounds.clone() until we really find a possible match
                if (ts==null) ts = fac.noneOf(expr.arity());
                if (!ts.containsAll(b.lowerBound((Relation)expr))) return null; // Sanity check
                if (!b.upperBound((Relation)expr).containsAll(ts)) return null; // Sanity check
                b.boundExactly((Relation)expr, ts);
                ts=null;
                continue;
             }
          }
          SATFactory sat = solver.options().solver();
View Full Code Here

TOP

Related Classes of kodkod.instance.Bounds

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.