Search in sources :

Example 81 with Formula

use of kodkod.ast.Formula in project org.alloytools.alloy by AlloyTools.

the class LAT258 method lowerBoundMeet.

/**
 * Returns the lower_bound_meet axiom.
 *
 * @return the lower_bound_meet axiom.
 */
public final Formula lowerBoundMeet() {
    final Variable c = Variable.unary("C");
    final Expression e0 = c.join(lessThan);
    final Formula f0 = meet.join(c).in(e0.product(e0));
    // all c: univ | meet.c in c.lessThan->c.lessThan
    return f0.forAll(c.oneOf(UNIV));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 82 with Formula

use of kodkod.ast.Formula in project org.alloytools.alloy by AlloyTools.

the class LAT258 method main.

/**
 * Usage: java examples.tptp.LAT258 [scope]
 */
public static void main(String[] args) {
    if (args.length < 1)
        usage();
    try {
        final int n = Integer.parseInt(args[0]);
        final LAT258 model = new LAT258();
        final Bounds b = model.bounds(n);
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final Formula f = model.checkGoalToBeProved();
        System.out.println(f);
        // System.out.println(b);
        final Solution s = solver.solve(f, b);
        System.out.println(s);
    } catch (NumberFormatException nfe) {
        usage();
    } catch (HigherOrderDeclException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnboundLeafException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) UnboundLeafException(kodkod.engine.fol2sat.UnboundLeafException) Bounds(kodkod.instance.Bounds) HigherOrderDeclException(kodkod.engine.fol2sat.HigherOrderDeclException) Solution(kodkod.engine.Solution)

Example 83 with Formula

use of kodkod.ast.Formula in project org.alloytools.alloy by AlloyTools.

the class LAT258 method greatestLowerBoundMeet.

/*
     * fof(greatest_lower_bound_meet,axiom,( ! [A,B,C,D] : ( ( meet(A,B,C) &
     * less_than(D,A) & less_than(D,B) ) => less_than(D,C) ) )).
     */
/**
 * Returns the greatest_lower_bound_meet axiom.
 *
 * @return the greatest_lower_bound_meet axiom.
 */
public final Formula greatestLowerBoundMeet() {
    final Variable a = Variable.unary("A"), b = Variable.unary("B");
    final Expression e0 = b.join(a.join(meet));
    final Formula f0 = e0.some().implies(lessThan.join(a).intersection(lessThan.join(b)).in(lessThan.join(e0)));
    return f0.forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 84 with Formula

use of kodkod.ast.Formula in project org.alloytools.alloy by AlloyTools.

the class LAT258 method loLeDistr.

/**
 * Returns the lo_le_distr axiom.
 *
 * @return the lo_le_distr axiom.
 */
public final Formula loLeDistr() {
    final Variable a = Variable.unary("A"), b = Variable.unary("B"), c = Variable.unary("C");
    final Expression h = c.join(b.join(join));
    final Expression d = h.join(a.join(meet));
    final Expression e = b.join(a.join(meet));
    final Expression f = c.join(a.join(meet));
    final Expression g = f.join(e.join(join));
    final Formula f0 = d.product(g).in(lessThan);
    // (c.(a.meet)).((b.(a.meet)).join) in lessThan
    return f0.forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)).and(c.oneOf(UNIV)));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 85 with Formula

use of kodkod.ast.Formula in project org.alloytools.alloy by AlloyTools.

the class CeilingsAndFloors method noSharing.

/**
 * Returns the noSharing constraint.
 *
 * @return all m, n: Man | !(m = n) => !(m.floor = n.floor || m.ceiling =
 *         n.ceiling)
 */
public Formula noSharing() {
    final Variable m = Variable.unary("m1"), n = Variable.unary("n1");
    // all m, n: Man | !(m = n) => !(m.floor = n.floor || m.ceiling =
    // n.ceiling)
    final Formula body = (m.join(floor).eq(n.join(floor))).or(m.join(ceiling).eq(n.join(ceiling)));
    return (m.eq(n).not().implies(body.not())).forAll(m.oneOf(Man).and(n.oneOf(Man)));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable)

Aggregations

Formula (kodkod.ast.Formula)346 Variable (kodkod.ast.Variable)151 Solution (kodkod.engine.Solution)101 Expression (kodkod.ast.Expression)95 Bounds (kodkod.instance.Bounds)83 QuantifiedFormula (kodkod.ast.QuantifiedFormula)72 Solver (kodkod.engine.Solver)67 BinaryFormula (kodkod.ast.BinaryFormula)50 NaryFormula (kodkod.ast.NaryFormula)49 Relation (kodkod.ast.Relation)45 NotFormula (kodkod.ast.NotFormula)43 ComparisonFormula (kodkod.ast.ComparisonFormula)40 IntExpression (kodkod.ast.IntExpression)40 IntComparisonFormula (kodkod.ast.IntComparisonFormula)39 MultiplicityFormula (kodkod.ast.MultiplicityFormula)39 Universe (kodkod.instance.Universe)37 ArrayList (java.util.ArrayList)35 TupleFactory (kodkod.instance.TupleFactory)35 ConstantFormula (kodkod.ast.ConstantFormula)29 TupleSet (kodkod.instance.TupleSet)29