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);
}
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
}
Aggregations