Search in sources :

Example 11 with Decl

use of edu.mit.csail.sdg.ast.Decl in project org.alloytools.alloy by AlloyTools.

the class DemoFileSystem method makeDomain.

void makeDomain() throws Err {
    // abstract sig Obj { parent: lone Dir }
    // abstract sig Dir extends Obj { contains: set Obj }
    // abstract sig File extends Obj { }
    // one sig Root extends Dir { }
    obj = makeSig("Obj", true, false);
    dir = makeSig(obj, "Dir", true, false);
    file = makeSig(obj, "File", true, false);
    root = makeSig(dir, "Root", false, true);
    parent = obj.addField("parent", dir.loneOf());
    contains = dir.addField("contains", obj.setOf());
    // fact { all x:Obj-Root | one x.parent }
    Decl x = obj.minus(root).oneOf("x");
    fact = x.get().join(parent).one().forAll(x).and(fact);
    // fact { contains = ~ parent }
    fact = contains.equal(parent.transpose()).and(fact);
    // fact { acyclic[contains] }
    fact = acyclic(contains).and(fact);
}
Also used : Decl(edu.mit.csail.sdg.ast.Decl)

Example 12 with Decl

use of edu.mit.csail.sdg.ast.Decl in project org.alloytools.alloy by AlloyTools.

the class DemoFileSystem method acyclic.

/*
     * These corresponds to the helper predicates/functions provided in util/*.als
     */
static Expr acyclic(Expr r) throws Err {
    // x is a variable over the domain
    Decl d = r.join(Sig.UNIV).oneOf("x");
    // of r
    ExprHasName x = d.get();
    // (x !in x.^r) for
    return x.in(x.join(r.closure())).not().forAll(d);
// all x
}
Also used : ExprHasName(edu.mit.csail.sdg.ast.ExprHasName) Decl(edu.mit.csail.sdg.ast.Decl)

Aggregations

Decl (edu.mit.csail.sdg.ast.Decl)12 ExprHasName (edu.mit.csail.sdg.ast.ExprHasName)9 Expr (edu.mit.csail.sdg.ast.Expr)8 Func (edu.mit.csail.sdg.ast.Func)5 Sig (edu.mit.csail.sdg.ast.Sig)4 Err (edu.mit.csail.sdg.alloy4.Err)3 Command (edu.mit.csail.sdg.ast.Command)3 Field (edu.mit.csail.sdg.ast.Sig.Field)3 ErrorSyntax (edu.mit.csail.sdg.alloy4.ErrorSyntax)2 ErrorWarning (edu.mit.csail.sdg.alloy4.ErrorWarning)2 ExprVar (edu.mit.csail.sdg.ast.ExprVar)2 Module (edu.mit.csail.sdg.ast.Module)2 PrimSig (edu.mit.csail.sdg.ast.Sig.PrimSig)2 A4Options (edu.mit.csail.sdg.translator.A4Options)2 A4Solution (edu.mit.csail.sdg.translator.A4Solution)2 ArrayList (java.util.ArrayList)2 BinaryExpression (kodkod.ast.BinaryExpression)2 Expression (kodkod.ast.Expression)2 IntExpression (kodkod.ast.IntExpression)2 TempList (edu.mit.csail.sdg.alloy4.ConstList.TempList)1