Package kodkod.instance

Examples of kodkod.instance.Tuple


        return tmp.isEmpty();
    }

    /** Parse tuple. */
    private Tuple parseTuple(XMLNode tuple, int arity) throws Err {
        Tuple ans = null;
        try {
            for(XMLNode sub:tuple) if (sub.is("atom")) {
                Tuple x = factory.tuple(sub.getAttribute("label"));
                if (ans==null) ans=x; else ans=ans.product(x);
            }
            if (ans==null) throw new ErrorFatal("Expecting: <tuple> <atom label=\"..\"/> .. </tuple>");
            if (ans.arity()!=arity) throw new ErrorFatal("Expecting: tuple of arity "+arity+" but got tuple of arity "+ans.arity());
            return ans;
View Full Code Here


        TupleSet sigintBounds = factory.noneOf(1);
        TupleSet seqidxBounds = factory.noneOf(1);
        TupleSet stringBounds = factory.noneOf(1);
        final TupleSet next = factory.noneOf(2);
        for(int min=min(), max=max(), i=min; i<=max; i++) { // Safe since we know 1 <= bitwidth <= 30
           Tuple ii = factory.tuple(""+i);
           TupleSet is = factory.range(ii, ii);
           bounds.boundExactly(i, is);
           sigintBounds.add(ii);
           if (i>=0 && i<maxseq) seqidxBounds.add(ii);
           if (i+1<=max) next.add(factory.tuple(""+i, ""+(i+1)));
           if (i==min) bounds.boundExactly(KK_MIN,  is);
           if (i==max) bounds.boundExactly(KK_MAX,  is);
           if (i==0)   bounds.boundExactly(KK_ZERO, is);
        }
        this.sigintBounds = sigintBounds.unmodifiableView();
        this.seqidxBounds = seqidxBounds.unmodifiableView();
        bounds.boundExactly(KK_NEXT, next);
        bounds.boundExactly(KK_SEQIDX, this.seqidxBounds);
        Map<String,Expression> s2k = new HashMap<String,Expression>();
        for(String e: stringAtoms) {
            Relation r = Relation.unary("");
            Tuple t = factory.tuple(e);
            s2k.put(e, r);
            bounds.boundExactly(r, factory.range(t, t));
            stringBounds.add(t);
        }
        this.s2k = ConstMap.make(s2k);
View Full Code Here

       final int n = u.size();
       final List<Tuple> list = new ArrayList<Tuple>(n);
       if (b.size() == 0 && n <= 1) return list;
       if (b.size() != n-1) return null;
       // Find the starting element
       Tuple head = null;
       TupleSet right = b.project(1);
       for(Tuple x: u) if (!right.contains(x)) {head = x; break;}
       if (head==null) return null;
       final TupleFactory f = head.universe().factory();
       // Form the list
       list.add(head);
       while(true) {
          // Find head.next
          Tuple headnext = null;
          for(Tuple x: b) if (x.atom(0)==head.atom(0)) { headnext = f.tuple(x.atom(1)); break; }
          // If we've reached the end of the chain, and indeed we've formed exactly n elements (and all are in u), we're done
          if (headnext==null) return list.size()==n ? list : null;
          // If we've accumulated more than n elements, or if we reached an element not in u, then we declare failure
          if (list.size()==n || !u.contains(headnext)) return null;
View Full Code Here

        if (solved) return this;
        // If cmd==null, then all four arguments are ignored, and we simply use the lower bound of each relation
        if (cmd==null) {
           Instance inst = new Instance(bounds.universe());
           for(int max=max(), i=min(); i<=max; i++) {
              Tuple it = factory.tuple(""+i);
              inst.add(i, factory.range(it, it));
           }
           for(Relation r: bounds.relations()) inst.add(r, bounds.lowerBound(r));
           eval = new Evaluator(inst, solver.options());
           rename(this, null, null, new UniqueNameGenerator());
           solved();
           return this;
        }
        // Otherwise, prepare to do the solve...
        final A4Options opt = originalOptions;
        long time = System.currentTimeMillis();
        rep.debug("Simplifying the bounds...\n");
        if (simp!=null && formulas.size()>0 && !simp.simplify(rep, this, formulas)) addFormula(Formula.FALSE, Pos.UNKNOWN);
        rep.translate(opt.solver.id(), bitwidth, maxseq, solver.options().skolemDepth(), solver.options().symmetryBreaking());
        Formula fgoal = Formula.and(formulas);
        rep.debug("Generating the solution...\n");
        kEnumerator = null;
        Solution sol = null;
        final Reporter oldReporter = solver.options().reporter();
        final boolean solved[] = new boolean[]{true};
        solver.options().setReporter(new AbstractReporter() { // Set up a reporter to catch the type+pos of skolems
            @Override public void skolemizing(Decl decl, Relation skolem, List<Decl> predecl) {
                try {
                    Type t=kv2typepos(decl.variable()).a;
                    if (t==Type.EMPTY) return;
                    for(int i=(predecl==null ? -1 : predecl.size()-1); i>=0; i--) {
                        Type pp=kv2typepos(predecl.get(i).variable()).a;
                        if (pp==Type.EMPTY) return;
                        t=pp.product(t);
                    }
                    kr2type(skolem, t);
                } catch(Throwable ex) { } // Exception here is not fatal
            }
            @Override public void solvingCNF(int primaryVars, int vars, int clauses) {
               if (solved[0]) return; else solved[0]=true; // initially solved[0] is true, so we won't report the # of vars/clauses
               if (rep!=null) rep.solve(primaryVars, vars, clauses);
           }
        });
        if (!opt.solver.equals(SatSolver.CNF) && !opt.solver.equals(SatSolver.KK) && tryBookExamples) { // try book examples
           A4Reporter r = "yes".equals(System.getProperty("debug")) ? rep : null;
           try { sol = BookExamples.trial(r, this, fgoal, solver, cmd.check); } catch(Throwable ex) { sol = null; }
        }
        solved[0] = false; // this allows the reporter to report the # of vars/clauses
        for(Relation r: bounds.relations()) { formulas.add(r.eq(r)); } // Without this, kodkod refuses to grow unmentioned relations
        fgoal = Formula.and(formulas);
        // Now pick the solver and solve it!
        if (opt.solver.equals(SatSolver.KK)) {
            File tmpCNF = File.createTempFile("tmp", ".java", new File(opt.tempDirectory));
            String out = tmpCNF.getAbsolutePath();
            Util.writeAll(out, debugExtractKInput());
            rep.resultCNF(out);
            return null;
         }
        if (opt.solver.equals(SatSolver.CNF)) {
            File tmpCNF = File.createTempFile("tmp", ".cnf", new File(opt.tempDirectory));
            String out = tmpCNF.getAbsolutePath();
            solver.options().setSolver(WriteCNF.factory(out));
            try { sol = solver.solve(fgoal, bounds); } catch(WriteCNF.WriteCNFCompleted ex) { rep.resultCNF(out); return null; }
            // The formula is trivial (otherwise, it would have thrown an exception)
            // Since the user wants it in CNF format, we manually generate a trivially satisfiable (or unsatisfiable) CNF file.
            Util.writeAll(out, sol.instance()!=null ? "p cnf 1 1\n1 0\n" : "p cnf 1 2\n1 0\n-1 0\n");
            rep.resultCNF(out);
            return null;
         }
        if (solver.options().solver()==SATFactory.ZChaff || !solver.options().solver().incremental()) {
           rep.debug("Begin solve()\n");
           if (sol==null) sol = solver.solve(fgoal, bounds);
           rep.debug("End solve()\n");
        } else {
           rep.debug("Begin solveAll()\n");
           kEnumerator = new Peeker<Solution>(solver.solveAll(fgoal, bounds));
           if (sol==null) sol = kEnumerator.next();
           rep.debug("End solveAll()\n");
        }
        if (!solved[0]) rep.solve(0, 0, 0);
        final Instance inst = sol.instance();
        // To ensure no more output during SolutionEnumeration
        solver.options().setReporter(oldReporter);
        // If unsatisfiable, then retreive the unsat core if desired
        if (inst==null && solver.options().solver()==SATFactory.MiniSatProver) {
           try {
              lCore = new LinkedHashSet<Node>();
              Proof p = sol.proof();
              if (sol.outcome()==UNSATISFIABLE) {
                 // only perform the minimization if it was UNSATISFIABLE, rather than TRIVIALLY_UNSATISFIABLE
                 int i = p.highLevelCore().size();
                 rep.minimizing(cmd, i);
                 if (opt.coreMinimization==0) try { p.minimize(new RCEStrategy(p.log())); } catch(Throwable ex) {}
                 if (opt.coreMinimization==1) try { p.minimize(new HybridStrategy(p.log())); } catch(Throwable ex) {}
                 rep.minimized(cmd, i, p.highLevelCore().size());
              }
              for(Iterator<TranslationRecord> it=p.core(); it.hasNext();) {
                 Object n=it.next().node();
                 if (n instanceof Formula) lCore.add((Formula)n);
              }
              Map<Formula,Node> map = p.highLevelCore();
              hCore = new LinkedHashSet<Node>(map.keySet());
              hCore.addAll(map.values());
View Full Code Here

        TupleSet lower = factory.noneOf(1);
        for(PrimSig c:sig.children()) lower.addAll(computeLowerBound(atoms, c));
        TupleSet upper = lower.clone();
        boolean isExact = sc.isExact(sig);
        if (isExact || sig.isTopLevel()) for(n=n-upper.size(); n>0; n--) {
           Tuple atom = atoms.remove(atoms.size()-1);
           // If MUST<SCOPE and s is exact, then add fresh atoms to both LOWERBOUND and UPPERBOUND.
           // If MUST<SCOPE and s is inexact but toplevel, then add fresh atoms to the UPPERBOUND.
           if (isExact) lower.add(atom);
           upper.add(atom);
        }
View Full Code Here

        public GreedySimulator() { }
        private TupleSet convert(TupleFactory factory, Expr f) throws Err {
            TupleSet old = ((A4TupleSet) (partial.eval(f))).debugGetKodkodTupleset();
            TupleSet ans = factory.noneOf(old.arity());
            for(Tuple oldT: old) {
                Tuple newT = null;
                for(int i=0; i<oldT.arity(); i++) {
                    if (newT==null) newT=factory.tuple(oldT.atom(i)); else newT=newT.product(factory.tuple(oldT.atom(i)));
                }
                ans.add(newT);
            }
            return ans;
        }
View Full Code Here

                if (s.isOne!=null && s.getFields().size()==2)
                  for(int i=0; i+3<totalOrderPredicates.size(); i=i+4)
                      if (totalOrderPredicates.get(i+1)==right(sol.a2k(s.getFields().get(0))) && totalOrderPredicates.get(i+3)==right(sol.a2k(s.getFields().get(1)))) {
                          TupleSet allelem = sol.query(true, totalOrderPredicates.get(i), true);
                          if (allelem.size()==0) continue;
                          Tuple first=null, prev=null; TupleSet next=factory.noneOf(2);
                          for(Tuple t:allelem) {
                              if (prev==null) first=t; else next.add(prev.product(t));
                              prev=t;
                          }
                          try {
View Full Code Here

    static Solution trial (A4Reporter rep, A4Solution frame, Formula formula, Solver solver, boolean check) {
        TupleFactory fac = frame.getFactory();
        Solution sol = null;
        Iterable<Sig> sigs = frame.getAllReachableSigs();
        if (hasSig(sigs, "this/Book")!=null) {
            Tuple B0N0A0 = t_tuple(fac, "Book$0", "Name$0", "Addr$0");
            Tuple B0N1A0 = t_tuple(fac, "Book$0", "Name$1", "Addr$0");
            Tuple B0N2A0 = t_tuple(fac, "Book$0", "Name$2", "Addr$0");
            Tuple B0N2A1 = t_tuple(fac, "Book$0", "Name$2", "Addr$1");
            Tuple B0N1A1 = t_tuple(fac, "Book$0", "Name$1", "Addr$1");
            Tuple B1N0A0 = t_tuple(fac, "Book$1", "Name$0", "Addr$0");
            Tuple B1N2A1 = t_tuple(fac, "Book$1", "Name$2", "Addr$1");
            Tuple B1N1A1 = t_tuple(fac, "Book$1", "Name$1", "Addr$1");
            Tuple B000 = t_tuple(fac, "Book$0", "Target$0", "Target$0");
            Tuple B001 = t_tuple(fac, "Book$0", "Target$0", "Target$1");
            Tuple B002 = t_tuple(fac, "Book$0", "Target$0", "Target$2");
            Tuple B010 = t_tuple(fac, "Book$0", "Target$1", "Target$0");
            Tuple B101 = t_tuple(fac, "Book$1", "Target$0", "Target$1");
            Tuple B110 = t_tuple(fac, "Book$1", "Target$1", "Target$0");
            Tuple B102 = t_tuple(fac, "Book$1", "Target$0", "Target$2");
            Tuple B210 = t_tuple(fac, "Book$2", "Target$1", "Target$0");
            Tuple B202 = t_tuple(fac, "Book$2", "Target$0", "Target$2");
            Tuple B212 = t_tuple(fac, "Book$2", "Target$1", "Target$2");
            Tuple B302 = t_tuple(fac, "Book$3", "Target$0", "Target$2");
            Tuple B310 = t_tuple(fac, "Book$3", "Target$1", "Target$0");
            Tuple B312 = t_tuple(fac, "Book$3", "Target$1", "Target$2");
            if (sol==null && B000!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.9",
                    "Book$0", "", "this/Book", "",
                    "Target$0", "", "this/Alias", "",
                    "", "this/Group", "",
                    "", "this/Addr", "",
                    B000, "", "this/Book", "addr",
            });
            if (sol==null && B001!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.10",
                    "Book$0", "", "this/Book", "",
                    "", "this/Alias", "",
                    "Target$0", "", "this/Group", "",
                    "Target$1", "Target$2", "", "this/Addr", "",
                    B001, B002, "", "this/Book", "addr",
            });
            if (sol==null && B001!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.11",
                    "Book$0", "", "this/Book", "",
                    "Target$0", "", "this/Alias", "",
                    "", "this/Group", "",
                    "Target$1", "Target$2", "", "this/Addr", "",
                    B001, B002, "", "this/Book", "addr",
            });
            if (sol==null && B001!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.12",
                    "Book$0", "", "this/Book", "",
                    "Target$0", "", "this/Alias", "",
                    "Target$1", "", "this/Group", "",
                    "", "this/Addr", "",
                    B001, "", "this/Book", "addr",
            });
            if (sol==null && B010!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.13",
                    "Book$0", "Book$1", "", "this/Book", "",
                    "", "this/Alias", "",
                    "Target$0", "Target$1", "", "this/Group", "",
                    "Target$2", "", "this/Addr", "",
                    B010, B110, B102, "", "this/Book", "addr",
            });
            if (sol==null && B312!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.15",
                    "Book$0", "Book$1", "Book$2", "Book$3", "", "this/Book", "",
                    "", "this/Alias", "",
                    "Target$0", "Target$1", "", "this/Group", "",
                    "Target$2", "", "this/Addr", "",
                    B102, B210, B202, B212, B302, B312, "", "this/Book", "addr",
            });
            if (sol==null && B101!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.16",
                    "Book$0", "Book$1", "Book$2", "Book$3", "", "this/Book", "",
                    "Target$1", "", "this/Alias", "",
                    "Target$0", "", "this/Group", "",
                    "", "this/Addr", "",
                    B101, "", "this/Book", "addr",
            });
            if (sol==null && B102!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.17",
                    "Book$0", "Book$1", "Book$2", "Book$3", "", "this/Book", "",
                    "Target$0", "", "this/Alias", "",
                    "Target$1", "", "this/Group", "",
                    "Target$2", "", "this/Addr", "",
                    B102, B210, B310, B302, "", "this/Book", "addr",
            });
            if (sol==null && B0N0A0!=null && check)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.6",
                    "Book$0", "Book$1", "", "this/Book", "",
                    "Addr$0", "", "this/Addr", "",
                    "Name$0", "", "this/Name", "",
                    B0N0A0, "", "this/Book", "addr",
            });
            if (sol==null && B1N0A0!=null && !check)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.4",
                    "Book$0", "Book$1", "", "this/Book", "",
                    "Addr$0", "", "this/Addr", "",
                    "Name$0", "", "this/Name", "",
                    B1N0A0, "", "this/Book", "addr",
            });
            if (sol==null && B0N2A1!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.5",
                    "Book$0", "Book$1", "", "this/Book", "",
                    "Addr$0", "Addr$1", "", "this/Addr", "",
                    "Name$0", "Name$1", "Name$2", "", "this/Name", "",
                    B0N2A1, B0N1A1, B1N2A1, B1N1A1, B1N0A0, "", "this/Book", "addr",
            });
            if (sol==null && B0N0A0!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.1",
                    "Book$0", "", "this/Book", "",
                    "Addr$0", "", "this/Addr", "",
                    "Name$0", "", "this/Name", "",
                    B0N0A0, "", "this/Book", "addr",
            });
            if (sol==null && B0N0A0!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.2",
                    "Book$0", "", "this/Book", "",
                    "Addr$0", "", "this/Addr", "",
                    "Name$0", "Name$1", "Name$2", "", "this/Name", "",
                    B0N0A0, B0N1A0, B0N2A0, "", "this/Book", "addr",
            });
            if (sol==null && B0N0A0!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 2.3",
                    "Book$0", "", "this/Book", "",
                    "Addr$0", "Addr$1", "", "this/Addr", "",
                    "Name$0", "Name$1", "Name$2", "", "this/Name", "",
                    B0N0A0, B0N1A0, B0N2A1, "", "this/Book", "addr",
            });
            if (sol==null && B001!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 5.2",
                    "Book$0", "Book$1", "", "this/Book", "",
                    "Target$0", "", "this/Name", "",
                    "Target$1", "", "this/Addr", "",
                    B001, B101, "", "this/Book", "addr",
            });
            if (sol==null && B102!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 5.3",
                    "Book$0", "Book$1", "", "this/Book", "",
                    "Target$0", "Target$1", "", "this/Name", "",
                    "Target$2", "", "this/Addr", "",
                    B010, B110, B102, "", "this/Book", "addr",
            });
        }
        else if (hasSig(sigs, "this/Woman")!=null) {
            Tuple man0_woman0 = t_tuple(fac, "Person$1", "Person$0");
            Tuple man1_woman0 = t_tuple(fac, "Person$2", "Person$0");
            Tuple man0_woman1 = t_tuple(fac, "Person$1", "Person$3");
            Tuple man1_woman1 = t_tuple(fac, "Person$2", "Person$3");
            if (sol==null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 4.2",
                    "Person$1", "", "this/Man", "",
                    "Person$0", "", "this/Woman", "",
                    man0_woman0, "", "this/Man", "wife",
                    man0_woman0, "", "this/Person", "mother",
                    "", "this/Person", "father",
            });
            if (sol==null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 4.3",
                    "Person$1", "Person$2", "", "this/Man", "",
                    "Person$0", "Person$3", "", "this/Woman", "",
                    man1_woman0, man0_woman1, "", "this/Man", "wife",
                    man1_woman1, man0_woman0, "", "this/Person", "mother",
                    "", "this/Person", "father",
            });
        }
        else if (hasSig(sigs, "this/Process")!=null) {
            String p0="Process$0", p1="Process$1", p2="Process$2";
            String t0="Time$0", t1="Time$1", t2="Time$2", t3="Time$3";
            Tuple s20=t_tuple(fac,p2,p0), s01=t_tuple(fac,p0,p1), s12=t_tuple(fac,p1,p2);
            Tuple d000=t_tuple(fac,p0,p0,t0), d110=t_tuple(fac,p1,p1,t0), d220=t_tuple(fac,p2,p2,t0);
            Tuple d001=t_tuple(fac,p0,p0,t1), d021=t_tuple(fac,p0,p2,t1), d111=t_tuple(fac,p1,p1,t1);
            Tuple d002=t_tuple(fac,p0,p0,t2), d112=t_tuple(fac,p1,p1,t2), d122=t_tuple(fac,p1,p2,t2);
            Tuple d003=t_tuple(fac,p0,p0,t3), d113=t_tuple(fac,p1,p1,t3), d223=t_tuple(fac,p2,p2,t3);
            if (sol==null && d000!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 6.4",
                s20, s01, s12, "", "this/Process", "succ",
                d000,d110,d220,d001,d021,d111,d002,d112,d122,d003,d113,d223,"","this/Process","toSend",
                t_tuple(fac,p2,t3),"","this/Process","elected",
            });
        }
        else if (hasSig(sigs, "this/Desk")!=null) {
            String g0="Guest$0", g1="Guest$1", r="Room$0", k0="Key$0", k1="Key$1";
            String t0="Time$0", t1="Time$1", t2="Time$2", t3="Time$3", t4="Time$4", t5="Time$5";
            String c0="Card$0", c1="Card$1";
            if (sol==null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig E.3",
                t_tuple(fac,c0,k0), t_tuple(fac,c1,k1), "", "this/Card", "fst",
                t_tuple(fac,c0,k1), t_tuple(fac,c1,k0), "", "this/Card", "snd",
                t_tuple(fac,g0,c0,t1),
                t_tuple(fac,g0,c0,t2), t_tuple(fac,g1,c1,t2),
                t_tuple(fac,g0,c0,t3), t_tuple(fac,g1,c1,t3),
                t_tuple(fac,g0,c0,t4), t_tuple(fac,g1,c1,t4),
                t_tuple(fac,g0,c0,t5), t_tuple(fac,g1,c1,t5), "", "this/Guest", "cards",
                t_tuple(fac,r,k0,t0), t_tuple(fac,r,k0,t1), t_tuple(fac,r,k0,t2),
                t_tuple(fac,r,k1,t3), t_tuple(fac,r,k0,t4), t_tuple(fac,r,k1,t5), "", "this/Room", "key",
                t_tuple(fac,k1,t1),
                t_tuple(fac,k0,t2), t_tuple(fac,k1,t2),
                t_tuple(fac,k0,t3), t_tuple(fac,k1,t3),
                t_tuple(fac,k0,t4), t_tuple(fac,k1,t4),
                t_tuple(fac,k0,t5), t_tuple(fac,k1,t5), "", "this/Desk", "issued",
                t_tuple(fac,r,k0,t0), t_tuple(fac,r,k1,t1), t_tuple(fac,r,k0,t2),
                t_tuple(fac,r,k0,t3), t_tuple(fac,r,k0,t4), t_tuple(fac,r,k0,t5), "", "this/Desk", "prev"
            });
        }
        else if (hasSig(sigs, "this/FrontDesk")!=null) {
            String g0="Guest$0", g1="Guest$1", r="Room$0", k0="Key$0", k1="Key$1", k2="Key$2";
            String t0="Time$0", t1="Time$1", t2="Time$2", t3="Time$3", t4="Time$4";
            Tuple G0=t_tuple(fac,g0), G1=t_tuple(fac,g1);
            Tuple K0=t_tuple(fac,r,k0), K1=t_tuple(fac,r,k1), K2=t_tuple(fac,r,k2);
            Tuple K0T0=t_tuple(fac,r,k0,t0), K0T1=t_tuple(fac,r,k0,t1), K0T2=t_tuple(fac,r,k0,t2);
            Tuple K0T3=t_tuple(fac,r,k0,t3), K1T4=t_tuple(fac,r,k1,t4);
            Tuple F1=t_tuple(fac,r,k0,t0), F2=t_tuple(fac,r,k1,t1), F3=t_tuple(fac,r,k1,t2);
            Tuple F4=t_tuple(fac,r,k2,t3), F5=t_tuple(fac,r,k2,t4);
            Tuple GK1=t_tuple(fac,g0,k1,t1), GK2=t_tuple(fac,g0,k1,t2), GK3=t_tuple(fac,g0,k1,t3);
            Tuple GK4=t_tuple(fac,g1,k2,t3), GK5=t_tuple(fac,g0,k1,t4), GK6=t_tuple(fac,g1,k2,t4);
            Tuple O1=t_tuple(fac,r,g0,t1), O2=t_tuple(fac,r,g1,t3), O3=t_tuple(fac,r,g1,t4);
            if (sol==null && K0T0!=null)
                sol=trial(rep, fac, solver, sigs, formula, frame, new Object[]{"Fig 6.13",
                G0, G1, "", "this/Guest", "",
                K0, K1, K2, "", "this/Room", "keys",
                K0T0, K0T1, K0T2, K0T3, K1T4, "", "this/Room", "currentKey",
View Full Code Here

          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++;
View Full Code Here

TOP

Related Classes of kodkod.instance.Tuple

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.