Package edu.mit.csail.sdg.alloy4

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


  }

  public static long run(String theory) {
    VizGUI viz = null;
    int i = 0;
    A4Reporter rep = new A4Reporter() {
      @Override
      public void warning(ErrorWarning msg) {
        System.out.print("Relevance Warning:\n"
            + (msg.toString().trim()) + "\n\n");
        System.out.flush();
View Full Code Here


  }


 
  protected A4Reporter createA4Reporter() {
    return new A4Reporter() {
      @Override
      public void warning(ErrorWarning msg) {
        System.out.print("Relevance Warning:\n"
            + (msg.toString().trim()) + "\n\n");
        System.out.flush();
View Full Code Here

  @Override
  protected void initializeAlloyAnalyzer() {
    // Alloy4 sends diagnostic messages and progress reports to the
    // A4Reporter.
    A4Reporter rep = createA4Reporter();

    try {

      javaMetamodel = CompUtil.parseEverything_fromFile(rep, null,
          alloyTheory);
View Full Code Here

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

                      return;
                   }
                }
            }
            if (msg instanceof Err) {
                Err ex = (Err)msg;
                String text = "fatal";
                boolean fatal = false;
                if (ex instanceof ErrorSyntax) text="syntax"; else if (ex instanceof ErrorType) text="type"; else fatal=true;
                if (ex.pos==Pos.UNKNOWN)
                    span.logBold("A "+text+" error has occurred:  ");
                else
                    span.logLink("A "+text+" error has occurred:  ", "POS: "+ex.pos.x+" "+ex.pos.y+" "+ex.pos.x2+" "+ex.pos.y2+" "+ex.pos.filename);
                if (verbosity>2) {
                    span.log("(see the "); span.logLink("stacktrace", "MSG: "+ex.dump()); span.log(")\n");
                } else {
                    span.log("\n");
                }
                span.logIndented(ex.msg.trim());
                span.log("\n");
                if (fatal && latestVersion>Version.buildNumber())
                    span.logBold(
                       "\nNote: You are running Alloy build#"+Version.buildNumber()+
                       ",\nbut the most recent is Alloy build#"+latestVersion+
                       ":\n( version "+latestName+" )\nPlease try to upgrade to the newest version,"+
                       "\nas the problem may have been fixed already.\n");
                span.flush();
                if (!fatal) gui.doVisualize("POS: "+ex.pos.x+" "+ex.pos.y+" "+ex.pos.x2+" "+ex.pos.y2+" "+ex.pos.filename);
                return;
            }
            if (msg instanceof Throwable) { Throwable ex = (Throwable)msg; span.logBold(ex.toString().trim()+"\n"); span.flush(); return; }
            if (!(msg instanceof Object[])) return;
            Object[] array = (Object[]) msg;
            if (array[0].equals("pop")) { span.setLength(len2); String x=(String)(array[1]); if (viz!=null && x.length()>0) OurDialog.alert(x); }
            if (array[0].equals("declare")) { gui.doSetLatest((String)(array[1])); }
            if (array[0].equals("S2")) { len3=len2=span.getLength(); span.logBold(""+array[1]); }
View Full Code Here

     * <p> The resulting instance may or may not satisfy all facts, and should be checked for consistency.
     */
    public void init(Field field, SimTupleset value) throws Err {
        if (value==null) { sfs.remove(field); return; }
        if (!value.empty() && value.arity()!=field.type().arity()) throw new ErrorType("Evaluator encountered an error: field "+field.label+" arity must not be " + value.arity());
        if (field.defined) throw new ErrorAPI("Evaluator cannot prebind the value of a defined field.");
        sfs.put(field, value);
        cacheUNIV = null;
        cacheSTRING = null;
        cacheForConstants.clear();
    }
View Full Code Here

    /** Returns an arbitrary atom from an arbitrary tuple.
     * @throws - ErrorAPI if this tupleset is empty
     */
    public SimAtom getAtom() throws ErrorAPI {
        if (tuples.size()>0) return tuples.get(0).get(0);
        if (min>=max) throw new ErrorAPI("This tupleset is empty");
        return SimAtom.make(min);
    }
View Full Code Here

    /** Returns an arbitrary tuple.
     * @throws - ErrorAPI if this tupleset is empty
     */
    public SimTuple getTuple() throws ErrorAPI {
        if (tuples.size()>0) return tuples.get(0);
        if (min>=max) throw new ErrorAPI("This tupleset is empty");
        SimAtom a = SimAtom.make(min);
        if (next) return SimTuple.make(a, SimAtom.make(min+1)); else return SimTuple.make(a);
    }
View Full Code Here

    /** Returns a modifiable copy of the list of all i-th atom from all tuples in some arbitrary order (0 is first atom, 1 is second atom...)
     * @throws - ErrorAPI if this tupleset contains at least one tuple whose length is less than or equal to i
     */
    public List<SimAtom> getAllAtoms(int column) throws ErrorAPI {
        if (empty()) return new ArrayList<SimAtom>(0);
        if (column<0 || column>=arity()) throw new ErrorAPI("This tupleset does not have an \""+column+"th\" column.");
        IdentityHashMap<SimAtom,Boolean> ans = new IdentityHashMap<SimAtom,Boolean>();
        for(SimTuple x: this) ans.put(x.get(column), Boolean.TRUE);
        return new ArrayList<SimAtom>(ans.keySet());
    }
View Full Code Here

        solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT);
     }

    /** Construct a new A4Solution that is the continuation of the old one, but with the "next" instance. */
    private A4Solution(A4Solution old) throws Err {
        if (!old.solved) throw new ErrorAPI("This solution is not yet solved, so next() is not allowed.");
        if (old.kEnumerator==null) throw new ErrorAPI("This solution was not generated by an incremental SAT solver.\n" + "Solution enumeration is currently only implemented for MiniSat and SAT4J.");
        if (old.eval==null) throw new ErrorAPI("This solution is already unsatisfiable, so you cannot call next() to get the next solution.");
        Instance inst = old.kEnumerator.next().instance();
        unrolls = old.unrolls;
        originalOptions = old.originalOptions;
        originalCommand = old.originalCommand;
        bitwidth = old.bitwidth;
View Full Code Here

TOP

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

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.