Search in sources :

Example 61 with Solution

use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.

the class HOLSome4AllTest method testA1.

@Test
public void testA1() {
    // SAT: all s: ints | s < 0 => (all ns: set Node | #ns > s)
    Formula f = si.lt(I0).implies(ns.count().gt(si).forAll(ns.setOf(Node))).forAll(s.oneOf(Expression.INTS));
    Solution sol = solve(f);
    assertTrue(sol.sat());
}
Also used : QuantifiedFormula(kodkod.ast.QuantifiedFormula) Formula(kodkod.ast.Formula) Solution(kodkod.engine.Solution) Test(org.junit.Test)

Example 62 with Solution

use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.

the class HOLSome4AllTest method testE1ii.

@Test
public void testE1ii() {
    // SAT: some s: ints | all $s: set Node | #$s > s
    Variable ns = Variable.unary("$s");
    Formula f = ns.count().gt(si).forAll(ns.setOf(Node)).forSome(s.oneOf(Expression.INTS));
    Solution sol = solve(f);
    assertEquals(true, sol.sat());
    assertEquals(-1, evalS(sol));
}
Also used : QuantifiedFormula(kodkod.ast.QuantifiedFormula) Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Solution(kodkod.engine.Solution) Test(org.junit.Test)

Example 63 with Solution

use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.

the class HOLSome4AllTest method testE1i.

@Test
public void testE1i() {
    // SAT: some s: ints | all s: set Node | #s > s
    Variable ns = Variable.unary("s");
    Formula f = ns.count().gt(si).forAll(ns.setOf(Node)).forSome(s.oneOf(Expression.INTS));
    Solution sol = solve(f);
    assertEquals(true, sol.sat());
    assertEquals(-1, evalS(sol));
}
Also used : QuantifiedFormula(kodkod.ast.QuantifiedFormula) Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Solution(kodkod.engine.Solution) Test(org.junit.Test)

Example 64 with Solution

use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.

the class HOLSome4AllTest method testE5.

@Test
public void testE5() {
    // SAT: some Node && some s: ints | s >= 0 && (all ns: set Node | some
    // ns => #ns > s)
    Formula cnd = si.gte(I0);
    Formula f = Node.some().and(cnd.and(ns.some().implies(ns.count().gt(si)).forAll(ns.setOf(Node))).forSome(s.oneOf(Expression.INTS)));
    Solution sol = solve(f);
    assertEquals(true, sol.sat());
    assertEquals(0, evalS(sol));
}
Also used : QuantifiedFormula(kodkod.ast.QuantifiedFormula) Formula(kodkod.ast.Formula) Solution(kodkod.engine.Solution) Test(org.junit.Test)

Example 65 with Solution

use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.

the class HOLSome4AllTest method doTestParallel1.

private void doTestParallel1(Variable ns2) {
    // SAT: some s: ints {
    // all ns: set Node | #ns > s
    // all ns2: set Node | #ns2 > s
    // }
    Formula h1 = ns.count().gt(si).forAll(ns.setOf(Node));
    Formula h2 = ns2.count().gt(si).forAll(ns2.setOf(Node));
    Formula f = h1.and(h2).forSome(s.oneOf(Expression.INTS));
    Solution sol = solve(f);
    assertTrue(sol.sat());
    assertEquals(-1, evalS(sol));
}
Also used : QuantifiedFormula(kodkod.ast.QuantifiedFormula) Formula(kodkod.ast.Formula) Solution(kodkod.engine.Solution)

Aggregations

Solution (kodkod.engine.Solution)153 Formula (kodkod.ast.Formula)101 Bounds (kodkod.instance.Bounds)75 Solver (kodkod.engine.Solver)72 Universe (kodkod.instance.Universe)32 Relation (kodkod.ast.Relation)30 TupleFactory (kodkod.instance.TupleFactory)30 TupleSet (kodkod.instance.TupleSet)25 Variable (kodkod.ast.Variable)24 IntExpression (kodkod.ast.IntExpression)19 Expression (kodkod.ast.Expression)17 Test (org.junit.Test)16 QuantifiedFormula (kodkod.ast.QuantifiedFormula)15 Decls (kodkod.ast.Decls)11 Evaluator (kodkod.engine.Evaluator)10 HigherOrderDeclException (kodkod.engine.fol2sat.HigherOrderDeclException)7 UnboundLeafException (kodkod.engine.fol2sat.UnboundLeafException)7 ConsoleReporter (kodkod.engine.config.ConsoleReporter)6 Instance (kodkod.instance.Instance)6 ArrayList (java.util.ArrayList)5