Search in sources :

Example 6 with HigherOrderDeclException

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

the class BugTests method testFelix_08142006.

public final void testFelix_08142006() {
    Relation x0 = Relation.nary("/nodeOrd/Ord", 1);
    Relation x1 = Relation.nary("/msg/ord/Ord", 1);
    Relation x2 = Relation.nary("/msg/Tick", 1);
    Relation x3 = Relation.nary("/bool/False", 1);
    Relation x4 = Relation.nary("/bool/True", 1);
    Relation x5 = Relation.nary("/bool/Bool", 1);
    Relation x6 = Relation.nary("/RingLeadNodeState", 1);
    Relation x7 = Relation.nary("/msg/NodeState", 1);
    Relation x8 = Relation.nary("/MsgViz", 1);
    Relation x9 = Relation.nary("/msg/Msg", 1);
    Relation x10 = Relation.nary("/RingLeadMsgState", 1);
    Relation x11 = Relation.nary("/msg/MsgState", 1);
    Relation x12 = Relation.nary("/RingLeadNode", 1);
    Relation x13 = Relation.nary("/msg/Node", 1);
    Relation x14 = Relation.nary("/RingLeadNode.rightNeighbor", 2);
    Relation x15 = Relation.nary("/msg/MsgState.from", 2);
    Relation x16 = Relation.nary("/msg/MsgState.to", 2);
    Relation x17 = Relation.nary("/RingLeadMsgState.id", 2);
    Relation x18 = Relation.nary("/msg/Msg.state", 2);
    Relation x19 = Relation.nary("/msg/Msg.sentOn", 2);
    Relation x20 = Relation.nary("/msg/Msg.readOn", 3);
    Relation x21 = Relation.nary("/MsgViz.vFrom", 2);
    Relation x22 = Relation.nary("/MsgViz.vTo", 2);
    Relation x23 = Relation.nary("/MsgViz.vId", 2);
    Relation x24 = Relation.nary("/RingLeadNodeState.leader", 2);
    Relation x25 = Relation.nary("/msg/Tick.state", 3);
    Relation x26 = Relation.nary("/msg/Tick.visible", 3);
    Relation x27 = Relation.nary("/msg/Tick.read", 3);
    Relation x28 = Relation.nary("/msg/Tick.sent", 3);
    Relation x29 = Relation.nary("/msg/Tick.available", 2);
    Relation x30 = Relation.nary("/msg/Tick.needsToSend", 3);
    Relation x31 = Relation.nary("first_", 1);
    Relation x32 = Relation.nary("last_", 1);
    Relation x33 = Relation.nary("next_", 2);
    Relation x34 = Relation.nary("first_", 1);
    Relation x35 = Relation.nary("last_", 1);
    Relation x36 = Relation.nary("next_", 2);
    String[] atoms = { "-1", "-2", "-3", "-4", "-5", "-6", "-7", "-8", "0", "1", "2", "3", "4", "5", "6", "7", "Bool.0", "Bool.1", "Msg.0", "MsgState.0", "Node.0", "NodeState.0", "NodeState.1", "Ord.0", "Ord.1", "Tick.0", "Tick.1", "Tick.2" };
    java.util.ArrayList<String> atomlist = new java.util.ArrayList<String>();
    for (String a : atoms) atomlist.add(a);
    Universe universe = new Universe(atomlist);
    TupleFactory factory = universe.factory();
    Bounds bounds = new Bounds(universe);
    TupleSet x0_upper = factory.noneOf(1);
    x0_upper.add(factory.tuple("Ord.1"));
    bounds.bound(x0, x0_upper);
    TupleSet x1_upper = factory.noneOf(1);
    x1_upper.add(factory.tuple("Ord.0"));
    bounds.bound(x1, x1_upper);
    TupleSet x2_upper = factory.noneOf(1);
    x2_upper.add(factory.tuple("Tick.0"));
    x2_upper.add(factory.tuple("Tick.1"));
    x2_upper.add(factory.tuple("Tick.2"));
    bounds.boundExactly(x2, x2_upper);
    TupleSet x3_upper = factory.noneOf(1);
    x3_upper.add(factory.tuple("Bool.1"));
    bounds.bound(x3, x3_upper);
    TupleSet x4_upper = factory.noneOf(1);
    x4_upper.add(factory.tuple("Bool.0"));
    bounds.bound(x4, x4_upper);
    TupleSet x5_upper = factory.noneOf(1);
    x5_upper.add(factory.tuple("Bool.0"));
    x5_upper.add(factory.tuple("Bool.1"));
    bounds.bound(x5, x5_upper);
    TupleSet x6_upper = factory.noneOf(1);
    x6_upper.add(factory.tuple("NodeState.0"));
    x6_upper.add(factory.tuple("NodeState.1"));
    bounds.bound(x6, x6_upper);
    TupleSet x7_upper = factory.noneOf(1);
    x7_upper.add(factory.tuple("NodeState.0"));
    x7_upper.add(factory.tuple("NodeState.1"));
    bounds.bound(x7, x7_upper);
    TupleSet x8_upper = factory.noneOf(1);
    x8_upper.add(factory.tuple("Msg.0"));
    bounds.bound(x8, x8_upper);
    TupleSet x9_upper = factory.noneOf(1);
    x9_upper.add(factory.tuple("Msg.0"));
    bounds.bound(x9, x9_upper);
    TupleSet x10_upper = factory.noneOf(1);
    x10_upper.add(factory.tuple("MsgState.0"));
    bounds.bound(x10, x10_upper);
    TupleSet x11_upper = factory.noneOf(1);
    x11_upper.add(factory.tuple("MsgState.0"));
    bounds.bound(x11, x11_upper);
    TupleSet x12_upper = factory.noneOf(1);
    x12_upper.add(factory.tuple("Node.0"));
    bounds.bound(x12, x12_upper);
    TupleSet x13_upper = factory.noneOf(1);
    x13_upper.add(factory.tuple("Node.0"));
    bounds.boundExactly(x13, x13_upper);
    TupleSet x14_upper = factory.noneOf(2);
    x14_upper.add(factory.tuple("Node.0").product(factory.tuple("Node.0")));
    bounds.bound(x14, x14_upper);
    TupleSet x15_upper = factory.noneOf(2);
    x15_upper.add(factory.tuple("MsgState.0").product(factory.tuple("Node.0")));
    bounds.bound(x15, x15_upper);
    TupleSet x16_upper = factory.noneOf(2);
    x16_upper.add(factory.tuple("MsgState.0").product(factory.tuple("Node.0")));
    bounds.bound(x16, x16_upper);
    TupleSet x17_upper = factory.noneOf(2);
    x17_upper.add(factory.tuple("MsgState.0").product(factory.tuple("Node.0")));
    bounds.bound(x17, x17_upper);
    TupleSet x18_upper = factory.noneOf(2);
    x18_upper.add(factory.tuple("Msg.0").product(factory.tuple("MsgState.0")));
    bounds.bound(x18, x18_upper);
    TupleSet x19_upper = factory.noneOf(2);
    x19_upper.add(factory.tuple("Msg.0").product(factory.tuple("Tick.0")));
    x19_upper.add(factory.tuple("Msg.0").product(factory.tuple("Tick.1")));
    x19_upper.add(factory.tuple("Msg.0").product(factory.tuple("Tick.2")));
    bounds.bound(x19, x19_upper);
    TupleSet x20_upper = factory.noneOf(3);
    x20_upper.add(factory.tuple("Msg.0").product(factory.tuple("Node.0")).product(factory.tuple("Tick.0")));
    x20_upper.add(factory.tuple("Msg.0").product(factory.tuple("Node.0")).product(factory.tuple("Tick.1")));
    x20_upper.add(factory.tuple("Msg.0").product(factory.tuple("Node.0")).product(factory.tuple("Tick.2")));
    bounds.bound(x20, x20_upper);
    TupleSet x21_upper = factory.noneOf(2);
    x21_upper.add(factory.tuple("Msg.0").product(factory.tuple("Node.0")));
    bounds.bound(x21, x21_upper);
    TupleSet x22_upper = factory.noneOf(2);
    x22_upper.add(factory.tuple("Msg.0").product(factory.tuple("Node.0")));
    bounds.bound(x22, x22_upper);
    TupleSet x23_upper = factory.noneOf(2);
    x23_upper.add(factory.tuple("Msg.0").product(factory.tuple("Node.0")));
    bounds.bound(x23, x23_upper);
    TupleSet x24_upper = factory.noneOf(2);
    x24_upper.add(factory.tuple("NodeState.0").product(factory.tuple("Bool.0")));
    x24_upper.add(factory.tuple("NodeState.0").product(factory.tuple("Bool.1")));
    x24_upper.add(factory.tuple("NodeState.1").product(factory.tuple("Bool.0")));
    x24_upper.add(factory.tuple("NodeState.1").product(factory.tuple("Bool.1")));
    bounds.bound(x24, x24_upper);
    TupleSet x25_upper = factory.noneOf(3);
    x25_upper.add(factory.tuple("Tick.0").product(factory.tuple("Node.0")).product(factory.tuple("NodeState.0")));
    x25_upper.add(factory.tuple("Tick.0").product(factory.tuple("Node.0")).product(factory.tuple("NodeState.1")));
    x25_upper.add(factory.tuple("Tick.1").product(factory.tuple("Node.0")).product(factory.tuple("NodeState.0")));
    x25_upper.add(factory.tuple("Tick.1").product(factory.tuple("Node.0")).product(factory.tuple("NodeState.1")));
    x25_upper.add(factory.tuple("Tick.2").product(factory.tuple("Node.0")).product(factory.tuple("NodeState.0")));
    x25_upper.add(factory.tuple("Tick.2").product(factory.tuple("Node.0")).product(factory.tuple("NodeState.1")));
    bounds.bound(x25, x25_upper);
    TupleSet x26_upper = factory.noneOf(3);
    x26_upper.add(factory.tuple("Tick.0").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0")));
    x26_upper.add(factory.tuple("Tick.1").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0")));
    x26_upper.add(factory.tuple("Tick.2").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0")));
    bounds.bound(x26, x26_upper);
    TupleSet x27_upper = factory.noneOf(3);
    x27_upper.add(factory.tuple("Tick.0").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0")));
    x27_upper.add(factory.tuple("Tick.1").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0")));
    x27_upper.add(factory.tuple("Tick.2").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0")));
    bounds.bound(x27, x27_upper);
    TupleSet x28_upper = factory.noneOf(3);
    x28_upper.add(factory.tuple("Tick.0").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0")));
    x28_upper.add(factory.tuple("Tick.1").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0")));
    x28_upper.add(factory.tuple("Tick.2").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0")));
    bounds.bound(x28, x28_upper);
    TupleSet x29_upper = factory.noneOf(2);
    x29_upper.add(factory.tuple("Tick.0").product(factory.tuple("Msg.0")));
    x29_upper.add(factory.tuple("Tick.1").product(factory.tuple("Msg.0")));
    x29_upper.add(factory.tuple("Tick.2").product(factory.tuple("Msg.0")));
    bounds.bound(x29, x29_upper);
    TupleSet x30_upper = factory.noneOf(3);
    x30_upper.add(factory.tuple("Tick.0").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0")));
    x30_upper.add(factory.tuple("Tick.1").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0")));
    x30_upper.add(factory.tuple("Tick.2").product(factory.tuple("Node.0")).product(factory.tuple("Msg.0")));
    bounds.bound(x30, x30_upper);
    TupleSet x31_upper = factory.noneOf(1);
    x31_upper.add(factory.tuple("Tick.0"));
    x31_upper.add(factory.tuple("Tick.1"));
    x31_upper.add(factory.tuple("Tick.2"));
    bounds.bound(x31, x31_upper);
    TupleSet x32_upper = factory.noneOf(1);
    x32_upper.add(factory.tuple("Tick.0"));
    x32_upper.add(factory.tuple("Tick.1"));
    x32_upper.add(factory.tuple("Tick.2"));
    bounds.bound(x32, x32_upper);
    TupleSet x33_upper = factory.noneOf(2);
    x33_upper.add(factory.tuple("Tick.0").product(factory.tuple("Tick.0")));
    x33_upper.add(factory.tuple("Tick.0").product(factory.tuple("Tick.1")));
    x33_upper.add(factory.tuple("Tick.0").product(factory.tuple("Tick.2")));
    x33_upper.add(factory.tuple("Tick.1").product(factory.tuple("Tick.0")));
    x33_upper.add(factory.tuple("Tick.1").product(factory.tuple("Tick.1")));
    x33_upper.add(factory.tuple("Tick.1").product(factory.tuple("Tick.2")));
    x33_upper.add(factory.tuple("Tick.2").product(factory.tuple("Tick.0")));
    x33_upper.add(factory.tuple("Tick.2").product(factory.tuple("Tick.1")));
    x33_upper.add(factory.tuple("Tick.2").product(factory.tuple("Tick.2")));
    bounds.bound(x33, x33_upper);
    TupleSet x34_upper = factory.noneOf(1);
    x34_upper.add(factory.tuple("Node.0"));
    bounds.bound(x34, x34_upper);
    TupleSet x35_upper = factory.noneOf(1);
    x35_upper.add(factory.tuple("Node.0"));
    bounds.bound(x35, x35_upper);
    TupleSet x36_upper = factory.noneOf(2);
    x36_upper.add(factory.tuple("Node.0").product(factory.tuple("Node.0")));
    bounds.bound(x36, x36_upper);
    bounds.boundExactly(-8, factory.range(factory.tuple("-8"), factory.tuple("-8")));
    bounds.boundExactly(-7, factory.range(factory.tuple("-7"), factory.tuple("-7")));
    bounds.boundExactly(-6, factory.range(factory.tuple("-6"), factory.tuple("-6")));
    bounds.boundExactly(-5, factory.range(factory.tuple("-5"), factory.tuple("-5")));
    bounds.boundExactly(-4, factory.range(factory.tuple("-4"), factory.tuple("-4")));
    bounds.boundExactly(-3, factory.range(factory.tuple("-3"), factory.tuple("-3")));
    bounds.boundExactly(-2, factory.range(factory.tuple("-2"), factory.tuple("-2")));
    bounds.boundExactly(-1, factory.range(factory.tuple("-1"), factory.tuple("-1")));
    bounds.boundExactly(0, factory.range(factory.tuple("0"), factory.tuple("0")));
    bounds.boundExactly(1, factory.range(factory.tuple("1"), factory.tuple("1")));
    bounds.boundExactly(2, factory.range(factory.tuple("2"), factory.tuple("2")));
    bounds.boundExactly(3, factory.range(factory.tuple("3"), factory.tuple("3")));
    bounds.boundExactly(4, factory.range(factory.tuple("4"), factory.tuple("4")));
    bounds.boundExactly(5, factory.range(factory.tuple("5"), factory.tuple("5")));
    bounds.boundExactly(6, factory.range(factory.tuple("6"), factory.tuple("6")));
    bounds.boundExactly(7, factory.range(factory.tuple("7"), factory.tuple("7")));
    Variable x41 = Variable.nary("@t", 1);
    Expression x44 = x1.product(x32);
    Expression x43 = x1.join(x44);
    Expression x42 = x2.difference(x43);
    Decls x40 = x41.oneOf(x42);
    Expression x48 = x41.join(x25);
    Expression x49 = x43.join(x25);
    Formula x47 = x48.eq(x49);
    Variable x52 = Variable.nary("@r", 2);
    Variable x59 = Variable.nary("VAR<future>", 1);
    Decls x58 = x59.oneOf(x9);
    Expression x61 = x59.join(x19);
    Expression x65 = x1.product(x33);
    Expression x64 = x1.join(x65);
    Expression x63 = x64.closure();
    Expression x62 = x41.join(x63);
    Formula x60 = x61.in(x62);
    Expression x57 = x60.comprehension(x58);
    Expression x56 = x9.difference(x57);
    Variable x68 = Variable.nary("VAR<past>", 1);
    Decls x67 = x68.oneOf(x9);
    Variable x71 = Variable.nary("@n", 1);
    Expression x73 = x68.join(x18);
    Expression x72 = x73.join(x16);
    Decls x70 = x71.oneOf(x72);
    Expression x76 = x68.join(x20);
    Expression x75 = x71.join(x76);
    Expression x81 = x33.transpose();
    Expression x80 = x1.product(x81);
    Expression x79 = x1.join(x80);
    Expression x78 = x79.closure();
    Expression x77 = x41.join(x78);
    Formula x74 = x75.in(x77);
    Formula x69 = x74.forAll(x70);
    Expression x66 = x69.comprehension(x67);
    Expression x55 = x56.difference(x66);
    Expression x83 = x41.join(x26);
    Expression x82 = x13.join(x83);
    Expression x54 = x55.difference(x82);
    Variable x89 = Variable.nary("VAR<future>", 1);
    Decls x88 = x89.oneOf(x9);
    Expression x91 = x89.join(x19);
    Expression x92 = x43.join(x63);
    Formula x90 = x91.in(x92);
    Expression x87 = x90.comprehension(x88);
    Expression x86 = x9.difference(x87);
    Variable x95 = Variable.nary("VAR<past>", 1);
    Decls x94 = x95.oneOf(x9);
    Variable x98 = Variable.nary("@n", 1);
    Expression x100 = x95.join(x18);
    Expression x99 = x100.join(x16);
    Decls x97 = x98.oneOf(x99);
    Expression x103 = x95.join(x20);
    Expression x102 = x98.join(x103);
    Expression x104 = x43.join(x78);
    Formula x101 = x102.in(x104);
    Formula x96 = x101.forAll(x97);
    Expression x93 = x96.comprehension(x94);
    Expression x85 = x86.difference(x93);
    Expression x106 = x43.join(x26);
    Expression x105 = x13.join(x106);
    Expression x84 = x85.difference(x105);
    Expression x53 = x54.product(x84);
    Decls x51 = x52.setOf(x53);
    Variable x117 = Variable.nary("VAR<future>", 1);
    Decls x116 = x117.oneOf(x9);
    Expression x119 = x117.join(x19);
    Formula x118 = x119.in(x62);
    Expression x115 = x118.comprehension(x116);
    Expression x114 = x9.difference(x115);
    Variable x122 = Variable.nary("VAR<past>", 1);
    Decls x121 = x122.oneOf(x9);
    Variable x125 = Variable.nary("@n", 1);
    Expression x127 = x122.join(x18);
    Expression x126 = x127.join(x16);
    Decls x124 = x125.oneOf(x126);
    Expression x130 = x122.join(x20);
    Expression x129 = x125.join(x130);
    Formula x128 = x129.in(x77);
    Formula x123 = x128.forAll(x124);
    Expression x120 = x123.comprehension(x121);
    Expression x113 = x114.difference(x120);
    Expression x112 = x113.difference(x82);
    Variable x136 = Variable.nary("VAR<future>", 1);
    Decls x135 = x136.oneOf(x9);
    Expression x138 = x136.join(x19);
    Formula x137 = x138.in(x92);
    Expression x134 = x137.comprehension(x135);
    Expression x133 = x9.difference(x134);
    Variable x141 = Variable.nary("VAR<past>", 1);
    Decls x140 = x141.oneOf(x9);
    Variable x144 = Variable.nary("@n", 1);
    Expression x146 = x141.join(x18);
    Expression x145 = x146.join(x16);
    Decls x143 = x144.oneOf(x145);
    Expression x149 = x141.join(x20);
    Expression x148 = x144.join(x149);
    Formula x147 = x148.in(x104);
    Formula x142 = x147.forAll(x143);
    Expression x139 = x142.comprehension(x140);
    Expression x132 = x133.difference(x139);
    Expression x131 = x132.difference(x105);
    Expression x111 = x112.product(x131);
    Formula x110 = x52.in(x111);
    Variable x152 = Variable.nary("@", 1);
    Variable x158 = Variable.nary("VAR<future>", 1);
    Decls x157 = x158.oneOf(x9);
    Expression x160 = x158.join(x19);
    Formula x159 = x160.in(x62);
    Expression x156 = x159.comprehension(x157);
    Expression x155 = x9.difference(x156);
    Variable x163 = Variable.nary("VAR<past>", 1);
    Decls x162 = x163.oneOf(x9);
    Variable x166 = Variable.nary("@n", 1);
    Expression x168 = x163.join(x18);
    Expression x167 = x168.join(x16);
    Decls x165 = x166.oneOf(x167);
    Expression x171 = x163.join(x20);
    Expression x170 = x166.join(x171);
    Formula x169 = x170.in(x77);
    Formula x164 = x169.forAll(x165);
    Expression x161 = x164.comprehension(x162);
    Expression x154 = x155.difference(x161);
    Expression x153 = x154.difference(x82);
    Decls x151 = x152.oneOf(x153);
    Expression x174 = x152.join(x52);
    Formula x173 = x174.one();
    Variable x181 = Variable.nary("VAR<future>", 1);
    Decls x180 = x181.oneOf(x9);
    Expression x183 = x181.join(x19);
    Formula x182 = x183.in(x92);
    Expression x179 = x182.comprehension(x180);
    Expression x178 = x9.difference(x179);
    Variable x186 = Variable.nary("VAR<past>", 1);
    Decls x185 = x186.oneOf(x9);
    Variable x189 = Variable.nary("@n", 1);
    Expression x191 = x186.join(x18);
    Expression x190 = x191.join(x16);
    Decls x188 = x189.oneOf(x190);
    Expression x194 = x186.join(x20);
    Expression x193 = x189.join(x194);
    Formula x192 = x193.in(x104);
    Formula x187 = x192.forAll(x188);
    Expression x184 = x187.comprehension(x185);
    Expression x177 = x178.difference(x184);
    Expression x176 = x177.difference(x105);
    Formula x175 = x174.in(x176);
    Formula x172 = x173.and(x175);
    Formula x150 = x172.forAll(x151);
    Formula x109 = x110.and(x150);
    Variable x197 = Variable.nary("@", 1);
    Decls x196 = x197.oneOf(x176);
    Expression x200 = x52.join(x197);
    Formula x199 = x200.one();
    Formula x201 = x200.in(x153);
    Formula x198 = x199.and(x201);
    Formula x195 = x198.forAll(x196);
    Formula x108 = x109.and(x195);
    Variable x204 = Variable.nary("@m1", 1);
    Expression x205 = x52.join(Expression.UNIV);
    Decls x203 = x204.oneOf(x205);
    Expression x209 = x9.product(Expression.UNIV);
    Expression x208 = x209.intersection(x18);
    Expression x207 = x204.join(x208);
    Expression x211 = x204.join(x52);
    Expression x210 = x211.join(x18);
    Formula x206 = x207.eq(x210);
    Formula x202 = x206.forAll(x203);
    Formula x107 = x108.and(x202);
    Formula x50 = x107.forSome(x51);
    Formula x46 = x47.and(x50);
    Variable x214 = Variable.nary("@r", 2);
    Expression x215 = x82.product(x105);
    Decls x213 = x214.setOf(x215);
    Formula x219 = x214.in(x215);
    Variable x222 = Variable.nary("@", 1);
    Decls x221 = x222.oneOf(x82);
    Expression x225 = x222.join(x214);
    Formula x224 = x225.one();
    Formula x226 = x225.in(x105);
    Formula x223 = x224.and(x226);
    Formula x220 = x223.forAll(x221);
    Formula x218 = x219.and(x220);
    Variable x229 = Variable.nary("@", 1);
    Decls x228 = x229.oneOf(x105);
    Expression x232 = x214.join(x229);
    Formula x231 = x232.one();
    Formula x233 = x232.in(x82);
    Formula x230 = x231.and(x233);
    Formula x227 = x230.forAll(x228);
    Formula x217 = x218.and(x227);
    Variable x236 = Variable.nary("@m1", 1);
    Expression x237 = x214.join(Expression.UNIV);
    Decls x235 = x236.oneOf(x237);
    Expression x239 = x236.join(x208);
    Expression x241 = x236.join(x214);
    Expression x240 = x241.join(x18);
    Formula x238 = x239.eq(x240);
    Formula x234 = x238.forAll(x235);
    Formula x216 = x217.and(x234);
    Formula x212 = x216.forSome(x213);
    Formula x45 = x46.and(x212);
    Formula x39 = x45.forSome(x40);
    Variable x244 = Variable.nary("@t", 1);
    Decls x243 = x244.oneOf(x2);
    Variable x248 = Variable.nary("@n", 1);
    Decls x247 = x248.oneOf(x13);
    Expression x252 = x244.join(x25);
    Expression x251 = x248.join(x252);
    Expression x250 = x251.join(x24);
    Formula x249 = x250.eq(x4);
    Formula x246 = x249.forSome(x247);
    Formula x245 = x246.not();
    Formula x242 = x245.forAll(x243);
    Formula x38 = x39.and(x242);
    Variable x256 = Variable.nary("@this", 1);
    Decls x255 = x256.oneOf(x2);
    Expression x260 = x256.join(x25);
    Expression x261 = x13.product(x7);
    Formula x259 = x260.in(x261);
    Variable x264 = Variable.nary("@", 1);
    Decls x263 = x264.oneOf(x13);
    Expression x267 = x264.join(x260);
    Formula x266 = x267.one();
    Formula x268 = x267.in(x7);
    Formula x265 = x266.and(x268);
    Formula x262 = x265.forAll(x263);
    Formula x258 = x259.and(x262);
    Variable x271 = Variable.nary("@", 1);
    Decls x270 = x271.oneOf(x7);
    Expression x273 = x260.join(x271);
    Formula x272 = x273.in(x13);
    Formula x269 = x272.forAll(x270);
    Formula x257 = x258.and(x269);
    Formula x254 = x257.forAll(x255);
    Expression x277 = x13.product(x9);
    Expression x276 = x2.product(x277);
    Formula x275 = x30.in(x276);
    Expression x280 = x2.product(x9);
    Formula x279 = x29.in(x280);
    Formula x282 = x28.in(x276);
    Formula x284 = x27.in(x276);
    Formula x286 = x26.in(x276);
    Expression x290 = x2.product(Expression.UNIV);
    Expression x289 = x290.product(Expression.UNIV);
    Formula x288 = x25.in(x289);
    Variable x294 = Variable.nary("@this", 1);
    Decls x293 = x294.oneOf(x9);
    Expression x300 = x294.join(x20);
    Expression x299 = x300.join(x2);
    Expression x302 = x294.join(x18);
    Expression x301 = x302.join(x16);
    Formula x298 = x299.in(x301);
    Formula x304 = x302.one();
    Formula x305 = x302.in(x11);
    Formula x303 = x304.and(x305);
    Formula x297 = x298.and(x303);
    Expression x308 = x294.join(x19);
    Formula x307 = x308.one();
    Formula x309 = x308.in(x2);
    Formula x306 = x307.and(x309);
    Formula x296 = x297.and(x306);
    Expression x313 = x13.product(x2);
    Formula x312 = x300.in(x313);
    Variable x316 = Variable.nary("@", 1);
    Decls x315 = x316.oneOf(x13);
    Expression x319 = x316.join(x300);
    Formula x318 = x319.lone();
    Formula x320 = x319.in(x2);
    Formula x317 = x318.and(x320);
    Formula x314 = x317.forAll(x315);
    Formula x311 = x312.and(x314);
    Variable x323 = Variable.nary("@", 1);
    Decls x322 = x323.oneOf(x2);
    Expression x325 = x300.join(x323);
    Formula x324 = x325.in(x13);
    Formula x321 = x324.forAll(x322);
    Formula x310 = x311.and(x321);
    Formula x295 = x296.and(x310);
    Formula x292 = x295.forAll(x293);
    Expression x328 = x209.product(Expression.UNIV);
    Formula x327 = x20.in(x328);
    Formula x330 = x19.in(x209);
    Formula x332 = x18.in(x209);
    Variable x336 = Variable.nary("@this", 1);
    Decls x335 = x336.oneOf(x11);
    Expression x339 = x336.join(x15);
    Formula x338 = x339.one();
    Formula x340 = x339.in(x13);
    Formula x337 = x338.and(x340);
    Formula x334 = x337.forAll(x335);
    Expression x343 = x11.product(x13);
    Formula x342 = x16.in(x343);
    Expression x346 = x11.product(Expression.UNIV);
    Formula x345 = x15.in(x346);
    Formula x348 = x27.in(x26);
    Expression x352 = x2.join(x28);
    Expression x351 = x13.join(x352);
    Formula x350 = x9.in(x351);
    Expression x360 = x1.product(x31);
    Expression x359 = x1.join(x360);
    Expression x358 = x359.join(x26);
    Expression x357 = x13.join(x358);
    Formula x356 = x357.no();
    Variable x363 = Variable.nary("@pre", 1);
    Decls x362 = x363.oneOf(x42);
    Expression x366 = x363.join(x64);
    Expression x365 = x366.join(x29);
    Expression x368 = x363.join(x29);
    Expression x370 = x363.join(x28);
    Expression x369 = x13.join(x370);
    Expression x367 = x368.difference(x369);
    Formula x364 = x365.eq(x367);
    Formula x361 = x364.forAll(x362);
    Formula x355 = x356.and(x361);
    Variable x373 = Variable.nary("@t", 1);
    Decls x372 = x373.oneOf(x2);
    Expression x382 = x373.join(x28);
    Expression x381 = x13.join(x382);
    Expression x383 = x373.join(x29);
    Formula x380 = x381.in(x383);
    Expression x385 = x381.join(x19);
    Formula x384 = x385.in(x373);
    Formula x379 = x380.and(x384);
    Expression x390 = x373.join(x27);
    Expression x389 = x13.join(x390);
    Expression x388 = x389.join(x20);
    Expression x387 = x13.join(x388);
    Formula x386 = x387.in(x373);
    Formula x378 = x379.and(x386);
    Formula x391 = x381.eq(x381);
    Formula x377 = x378.and(x391);
    Variable x394 = Variable.nary("@n", 1);
    Decls x393 = x394.oneOf(x13);
    Variable x397 = Variable.nary("@m", 1);
    Decls x396 = x397.oneOf(x9);
    Expression x401 = x397.join(x20);
    Expression x400 = x394.join(x401);
    Formula x399 = x400.eq(x373);
    Expression x403 = x394.join(x390);
    Formula x402 = x397.in(x403);
    Formula x398 = x399.implies(x402);
    Formula x395 = x398.forAll(x396);
    Formula x392 = x395.forAll(x393);
    Formula x376 = x377.and(x392);
    Variable x406 = Variable.nary("@n", 1);
    Decls x405 = x406.oneOf(x13);
    Expression x410 = x406.join(x382);
    Expression x409 = x410.join(x18);
    Expression x408 = x409.join(x15);
    Formula x407 = x408.in(x406);
    Formula x404 = x407.forAll(x405);
    Formula x375 = x376.and(x404);
    Variable x413 = Variable.nary("@n", 1);
    Decls x412 = x413.oneOf(x13);
    Variable x416 = Variable.nary("@m", 1);
    Decls x415 = x416.oneOf(x9);
    Expression x421 = x373.join(x26);
    Expression x420 = x413.join(x421);
    Formula x419 = x416.in(x420);
    Expression x425 = x416.join(x18);
    Expression x424 = x425.join(x16);
    Formula x423 = x413.in(x424);
    Expression x427 = x416.join(x19);
    Expression x428 = x373.join(x78);
    Formula x426 = x427.in(x428);
    Formula x422 = x423.and(x426);
    Formula x418 = x419.implies(x422);
    Expression x431 = x413.join(x390);
    Formula x430 = x416.in(x431);
    Expression x436 = x373.join(x63);
    Expression x435 = x436.join(x26);
    Expression x434 = x413.join(x435);
    Formula x433 = x416.in(x434);
    Formula x432 = x433.not();
    Formula x429 = x430.implies(x432);
    Formula x417 = x418.and(x429);
    Formula x414 = x417.forAll(x415);
    Formula x411 = x414.forAll(x412);
    Formula x374 = x375.and(x411);
    Formula x371 = x374.forAll(x372);
    Formula x354 = x355.and(x371);
    Variable x440 = Variable.nary("@this", 1);
    Decls x439 = x440.oneOf(x6);
    Expression x443 = x440.join(x24);
    Formula x442 = x443.one();
    Formula x444 = x443.in(x5);
    Formula x441 = x442.and(x444);
    Formula x438 = x441.forAll(x439);
    Expression x447 = x6.product(Expression.UNIV);
    Formula x446 = x24.in(x447);
    Variable x451 = Variable.nary("@this", 1);
    Decls x450 = x451.oneOf(x8);
    Expression x455 = x451.join(x21);
    Formula x454 = x455.one();
    Formula x456 = x455.in(x13);
    Formula x453 = x454.and(x456);
    Expression x459 = x451.join(x23);
    Formula x458 = x459.one();
    Formula x460 = x459.in(x13);
    Formula x457 = x458.and(x460);
    Formula x452 = x453.and(x457);
    Formula x449 = x452.forAll(x450);
    Expression x463 = x8.product(Expression.UNIV);
    Formula x462 = x23.in(x463);
    Expression x466 = x8.product(x13);
    Formula x465 = x22.in(x466);
    Formula x468 = x21.in(x463);
    Variable x472 = Variable.nary("@this", 1);
    Decls x471 = x472.oneOf(x10);
    Expression x475 = x472.join(x17);
    Formula x474 = x475.one();
    Formula x476 = x475.in(x13);
    Formula x473 = x474.and(x476);
    Formula x470 = x473.forAll(x471);
    Expression x479 = x10.product(Expression.UNIV);
    Formula x478 = x17.in(x479);
    Variable x483 = Variable.nary("@this", 1);
    Decls x482 = x483.oneOf(x12);
    Expression x486 = x483.join(x14);
    Formula x485 = x486.one();
    Formula x487 = x486.in(x13);
    Formula x484 = x485.and(x487);
    Formula x481 = x484.forAll(x482);
    Expression x490 = x12.product(Expression.UNIV);
    Formula x489 = x14.in(x490);
    Formula x494 = x12.eq(x13);
    Formula x495 = x10.eq(x11);
    Formula x493 = x494.and(x495);
    Formula x496 = x6.eq(x7);
    Formula x492 = x493.and(x496);
    Variable x500 = Variable.nary("@n", 1);
    Decls x499 = x500.oneOf(x13);
    Variable x504 = Variable.nary("@t", 1);
    Decls x503 = x504.oneOf(x42);
    Formula x507 = x504.eq(x359);
    Expression x514 = x504.join(x28);
    Expression x513 = x500.join(x514);
    Formula x512 = x513.one();
    Expression x518 = x504.join(x30);
    Expression x517 = x500.join(x518);
    IntExpression x516 = x517.count();
    IntExpression x519 = IntConstant.constant(1);
    Formula x515 = x516.eq(x519);
    Formula x511 = x512.and(x515);
    Expression x522 = x513.join(x18);
    Expression x521 = x522.join(x16);
    Expression x523 = x500.join(x14);
    Formula x520 = x521.eq(x523);
    Formula x510 = x511.and(x520);
    Expression x525 = x522.join(x17);
    Formula x524 = x525.eq(x500);
    Formula x509 = x510.and(x524);
    Expression x530 = x504.join(x64);
    Expression x529 = x530.join(x25);
    Expression x528 = x500.join(x529);
    Expression x527 = x528.join(x24);
    Formula x526 = x527.eq(x3);
    Formula x508 = x509.and(x526);
    Formula x506 = x507.implies(x508);
    Formula x532 = x507.not();
    Expression x539 = x504.join(x27);
    Expression x538 = x500.join(x539);
    Expression x541 = x504.join(x26);
    Expression x540 = x500.join(x541);
    Formula x537 = x538.eq(x540);
    Variable x544 = Variable.nary("@received", 1);
    Decls x543 = x544.oneOf(x538);
    Expression x548 = x544.join(x18);
    Expression x547 = x548.join(x17);
    Expression x552 = x0.product(x36);
    Expression x551 = x0.join(x552);
    Expression x550 = x551.closure();
    Expression x549 = x500.join(x550);
    Formula x546 = x547.in(x549);
    Variable x557 = Variable.nary("@weSend", 1);
    Decls x556 = x557.oneOf(x513);
    Variable x559 = Variable.nary("@weSend", 1);
    Decls x558 = x559.oneOf(x513);
    Decls x555 = x556.and(x558);
    Expression x565 = x557.join(x18);
    Expression x564 = x565.join(x17);
    Formula x563 = x564.eq(x547);
    Expression x567 = x565.join(x16);
    Formula x566 = x567.eq(x523);
    Formula x562 = x563.and(x566);
    Expression x571 = x559.join(x18);
    Expression x570 = x571.join(x17);
    Formula x569 = x570.eq(x547);
    Expression x573 = x571.join(x16);
    Formula x572 = x573.eq(x523);
    Formula x568 = x569.and(x572);
    Formula x561 = x562.and(x568);
    Formula x574 = x557.eq(x559);
    Formula x560 = x561.implies(x574);
    Formula x554 = x560.forAll(x555);
    Variable x577 = Variable.nary("@weSend", 1);
    Decls x576 = x577.oneOf(x513);
    Expression x581 = x577.join(x18);
    Expression x580 = x581.join(x17);
    Formula x579 = x580.eq(x547);
    Expression x583 = x581.join(x16);
    Formula x582 = x583.eq(x523);
    Formula x578 = x579.and(x582);
    Formula x575 = x578.forSome(x576);
    Formula x553 = x554.and(x575);
    Formula x545 = x546.implies(x553);
    Formula x542 = x545.forAll(x543);
    Formula x536 = x537.and(x542);
    Variable x586 = Variable.nary("@weSend", 1);
    Decls x585 = x586.oneOf(x513);
    Expression x591 = x586.join(x18);
    Expression x590 = x591.join(x17);
    Formula x589 = x590.in(x549);
    Expression x594 = x538.join(x18);
    Expression x593 = x594.join(x17);
    Formula x592 = x590.in(x593);
    Formula x588 = x589.and(x592);
    Expression x596 = x591.join(x16);
    Formula x595 = x596.eq(x523);
    Formula x587 = x588.and(x595);
    Formula x584 = x587.forAll(x585);
    Formula x535 = x536.and(x584);
    Variable x601 = Variable.nary("VAR<m>", 1);
    Decls x600 = x601.oneOf(x538);
    Expression x604 = x601.join(x18);
    Expression x603 = x604.join(x17);
    Formula x602 = x603.in(x549);
    Expression x599 = x602.comprehension(x600);
    IntExpression x598 = x599.count();
    Formula x597 = x516.eq(x598);
    Formula x534 = x535.and(x597);
    Formula x606 = x527.eq(x4);
    Expression x611 = x504.join(x25);
    Expression x610 = x500.join(x611);
    Expression x609 = x610.join(x24);
    Formula x608 = x609.eq(x4);
    Formula x612 = x500.in(x593);
    Formula x607 = x608.or(x612);
    Formula x605 = x606.iff(x607);
    Formula x533 = x534.and(x605);
    Formula x531 = x532.implies(x533);
    Formula x505 = x506.and(x531);
    Formula x502 = x505.forAll(x503);
    Expression x618 = x43.join(x27);
    Expression x617 = x500.join(x618);
    Expression x619 = x500.join(x106);
    Formula x616 = x617.eq(x619);
    Variable x622 = Variable.nary("@received", 1);
    Decls x621 = x622.oneOf(x617);
    Expression x626 = x622.join(x18);
    Expression x625 = x626.join(x17);
    Formula x624 = x625.in(x549);
    Variable x631 = Variable.nary("@weSend", 1);
    Expression x633 = x43.join(x28);
    Expression x632 = x500.join(x633);
    Decls x630 = x631.oneOf(x632);
    Variable x635 = Variable.nary("@weSend", 1);
    Decls x634 = x635.oneOf(x632);
    Decls x629 = x630.and(x634);
    Expression x641 = x631.join(x18);
    Expression x640 = x641.join(x17);
    Formula x639 = x640.eq(x625);
    Expression x643 = x641.join(x16);
    Formula x642 = x643.eq(x523);
    Formula x638 = x639.and(x642);
    Expression x647 = x635.join(x18);
    Expression x646 = x647.join(x17);
    Formula x645 = x646.eq(x625);
    Expression x649 = x647.join(x16);
    Formula x648 = x649.eq(x523);
    Formula x644 = x645.and(x648);
    Formula x637 = x638.and(x644);
    Formula x650 = x631.eq(x635);
    Formula x636 = x637.implies(x650);
    Formula x628 = x636.forAll(x629);
    Variable x653 = Variable.nary("@weSend", 1);
    Decls x652 = x653.oneOf(x632);
    Expression x657 = x653.join(x18);
    Expression x656 = x657.join(x17);
    Formula x655 = x656.eq(x625);
    Expression x659 = x657.join(x16);
    Formula x658 = x659.eq(x523);
    Formula x654 = x655.and(x658);
    Formula x651 = x654.forSome(x652);
    Formula x627 = x628.and(x651);
    Formula x623 = x624.implies(x627);
    Formula x620 = x623.forAll(x621);
    Formula x615 = x616.and(x620);
    Variable x662 = Variable.nary("@weSend", 1);
    Decls x661 = x662.oneOf(x632);
    Expression x667 = x662.join(x18);
    Expression x666 = x667.join(x17);
    Formula x665 = x666.in(x549);
    Expression x670 = x617.join(x18);
    Expression x669 = x670.join(x17);
    Formula x668 = x666.in(x669);
    Formula x664 = x665.and(x668);
    Expression x672 = x667.join(x16);
    Formula x671 = x672.eq(x523);
    Formula x663 = x664.and(x671);
    Formula x660 = x663.forAll(x661);
    Formula x614 = x615.and(x660);
    Expression x676 = x43.join(x30);
    Expression x675 = x500.join(x676);
    IntExpression x674 = x675.count();
    Variable x680 = Variable.nary("VAR<m>", 1);
    Decls x679 = x680.oneOf(x617);
    Expression x683 = x680.join(x18);
    Expression x682 = x683.join(x17);
    Formula x681 = x682.in(x549);
    Expression x678 = x681.comprehension(x679);
    IntExpression x677 = x678.count();
    Formula x673 = x674.eq(x677);
    Formula x613 = x614.and(x673);
    Formula x501 = x502.and(x613);
    Formula x498 = x501.forAll(x499);
    Variable x687 = Variable.nary("@n", 1);
    Decls x686 = x687.oneOf(x13);
    Expression x691 = x359.join(x25);
    Expression x690 = x687.join(x691);
    Expression x689 = x690.join(x24);
    Formula x688 = x689.eq(x3);
    Formula x685 = x688.forAll(x686);
    Formula x696 = x8.eq(x9);
    Expression x698 = x18.join(x15);
    Formula x697 = x21.eq(x698);
    Formula x695 = x696.and(x697);
    Expression x700 = x18.join(x16);
    Formula x699 = x22.eq(x700);
    Formula x694 = x695.and(x699);
    Expression x702 = x18.join(x17);
    Formula x701 = x23.eq(x702);
    Formula x693 = x694.and(x701);
    Formula x706 = x13.one();
    Variable x709 = Variable.nary("@n", 1);
    Decls x708 = x709.oneOf(x13);
    Expression x712 = x709.join(x14);
    Formula x711 = x709.eq(x712);
    Formula x710 = x711.not();
    Formula x707 = x710.forAll(x708);
    Formula x705 = x706.or(x707);
    Variable x715 = Variable.nary("@n", 1);
    Decls x714 = x715.oneOf(x13);
    Expression x718 = x14.closure();
    Expression x717 = x715.join(x718);
    Formula x716 = x13.in(x717);
    Formula x713 = x716.forAll(x714);
    Formula x704 = x705.and(x713);
    Formula x720 = x0.one();
    Formula x722 = x1.one();
    Formula x724 = x3.one();
    Formula x726 = x4.one();
    Expression x729 = x4.union(x3);
    Formula x728 = x729.eq(x5);
    Formula x731 = x6.in(x7);
    Formula x733 = x8.in(x9);
    Formula x735 = x10.in(x11);
    Formula x737 = x12.in(x13);
    Formula x739 = x36.totalOrder(x13, x34, x35);
    Formula x740 = x33.totalOrder(x2, x31, x32);
    Formula x738 = x739.and(x740);
    Formula x736 = x737.and(x738);
    Formula x734 = x735.and(x736);
    Formula x732 = x733.and(x734);
    Formula x730 = x731.and(x732);
    Formula x727 = x728.and(x730);
    Formula x725 = x726.and(x727);
    Formula x723 = x724.and(x725);
    Formula x721 = x722.and(x723);
    Formula x719 = x720.and(x721);
    Formula x703 = x704.and(x719);
    Formula x692 = x693.and(x703);
    Formula x684 = x685.and(x692);
    Formula x497 = x498.and(x684);
    Formula x491 = x492.and(x497);
    Formula x488 = x489.and(x491);
    Formula x480 = x481.and(x488);
    Formula x477 = x478.and(x480);
    Formula x469 = x470.and(x477);
    Formula x467 = x468.and(x469);
    Formula x464 = x465.and(x467);
    Formula x461 = x462.and(x464);
    Formula x448 = x449.and(x461);
    Formula x445 = x446.and(x448);
    Formula x437 = x438.and(x445);
    Formula x353 = x354.and(x437);
    Formula x349 = x350.and(x353);
    Formula x347 = x348.and(x349);
    Formula x344 = x345.and(x347);
    Formula x341 = x342.and(x344);
    Formula x333 = x334.and(x341);
    Formula x331 = x332.and(x333);
    Formula x329 = x330.and(x331);
    Formula x326 = x327.and(x329);
    Formula x291 = x292.and(x326);
    Formula x287 = x288.and(x291);
    Formula x285 = x286.and(x287);
    Formula x283 = x284.and(x285);
    Formula x281 = x282.and(x283);
    Formula x278 = x279.and(x281);
    Formula x274 = x275.and(x278);
    Formula x253 = x254.and(x274);
    Formula x37 = x38.and(x253);
    Solver solver = new Solver();
    // solver.options().setSolver(SATFactory.ZChaff);
    solver.options().setSolver(SATFactory.DefaultSAT4J);
    solver.options().setBitwidth(4);
    solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT);
    // System.out.println(x37);
    try {
        Solution sol = solver.solve(x37, bounds);
        assertNotNull(sol.instance());
    } catch (HigherOrderDeclException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnboundLeafException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : TupleSet(kodkod.instance.TupleSet) Solver(kodkod.engine.Solver) Variable(kodkod.ast.Variable) UnboundLeafException(kodkod.engine.fol2sat.UnboundLeafException) Decls(kodkod.ast.Decls) Bounds(kodkod.instance.Bounds) IntExpression(kodkod.ast.IntExpression) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe) Formula(kodkod.ast.Formula) Relation(kodkod.ast.Relation) IntExpression(kodkod.ast.IntExpression) Expression(kodkod.ast.Expression) HigherOrderDeclException(kodkod.engine.fol2sat.HigherOrderDeclException) Solution(kodkod.engine.Solution)

Example 7 with HigherOrderDeclException

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

the class TranslateAlloyToKodkod method execute_command.

/**
 * Based on the specified "options", execute one command and return the
 * resulting A4Solution object.
 *
 * @param rep - if nonnull, we'll send compilation diagnostic messages to it
 * @param sigs - the list of sigs; this list must be complete
 * @param cmd - the Command to execute
 * @param opt - the set of options guiding the execution of the command
 * @return null if the user chose "save to FILE" as the SAT solver, and nonnull
 *         if the solver finishes the entire solving and is either satisfiable
 *         or unsatisfiable.
 *         <p>
 *         If the return value X is satisfiable, you can call X.next() to get
 *         the next satisfying solution X2; and you can call X2.next() to get
 *         the next satisfying solution X3... until you get an unsatisfying
 *         solution.
 */
public static A4Solution execute_command(A4Reporter rep, Iterable<Sig> sigs, Command cmd, A4Options opt) throws Err {
    if (rep == null)
        rep = A4Reporter.NOP;
    TranslateAlloyToKodkod tr = null;
    try {
        if (cmd.parent != null || !cmd.getGrowableSigs().isEmpty())
            return execute_greedyCommand(rep, sigs, cmd, opt);
        tr = new TranslateAlloyToKodkod(rep, opt, sigs, cmd);
        tr.makeFacts(cmd.formula);
        return tr.frame.solve(rep, cmd, new Simplifier(), false);
    } catch (UnsatisfiedLinkError ex) {
        throw new ErrorFatal("The required JNI library cannot be found: " + ex.toString().trim(), ex);
    } catch (CapacityExceededException ex) {
        throw rethrow(ex);
    } catch (HigherOrderDeclException ex) {
        Pos p = tr != null ? tr.frame.kv2typepos(ex.decl().variable()).b : Pos.UNKNOWN;
        throw new ErrorType(p, "Analysis cannot be performed since it requires higher-order quantification that could not be skolemized.");
    } catch (Throwable ex) {
        if (ex instanceof Err)
            throw (Err) ex;
        else
            throw new ErrorFatal("Unknown exception occurred: " + ex, ex);
    }
}
Also used : CapacityExceededException(kodkod.engine.CapacityExceededException) ErrorFatal(edu.mit.csail.sdg.alloy4.ErrorFatal) ErrorType(edu.mit.csail.sdg.alloy4.ErrorType) Err(edu.mit.csail.sdg.alloy4.Err) Pos(edu.mit.csail.sdg.alloy4.Pos) HigherOrderDeclException(kodkod.engine.fol2sat.HigherOrderDeclException)

Example 8 with HigherOrderDeclException

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

the class TranslateAlloyToKodkod method execute_greedyCommand.

private static A4Solution execute_greedyCommand(A4Reporter rep, Iterable<Sig> sigs, Command usercommand, A4Options opt) throws Exception {
    // FIXTHIS: if the next command has a "smaller scope" than the last
    // command, we would get a Kodkod exception...
    // FIXTHIS: if the solver is "toCNF" or "toKodkod" then this method will
    // throw an Exception...
    // FIXTHIS: does solution enumeration still work when we're doing a
    // greedy solve?
    TranslateAlloyToKodkod tr = null;
    try {
        long start = System.currentTimeMillis();
        GreedySimulator sim = new GreedySimulator();
        sim.allSigs = sigs;
        sim.partial = null;
        A4Reporter rep2 = new A4Reporter(rep) {

            private boolean first = true;

            @Override
            public void translate(String solver, int bitwidth, int maxseq, int skolemDepth, int symmetry) {
                if (first)
                    super.translate(solver, bitwidth, maxseq, skolemDepth, symmetry);
                first = false;
            }

            @Override
            public void resultSAT(Object command, long solvingTime, Object solution) {
            }

            @Override
            public void resultUNSAT(Object command, long solvingTime, Object solution) {
            }
        };
        // Form the list of commands
        List<Command> commands = new ArrayList<Command>();
        while (usercommand != null) {
            commands.add(usercommand);
            usercommand = usercommand.parent;
        }
        // For each command...
        A4Solution sol = null;
        for (int i = commands.size() - 1; i >= 0; i--) {
            Command cmd = commands.get(i);
            sim.growableSigs = cmd.getGrowableSigs();
            while (cmd != null) {
                rep.debug(cmd.scope.toString());
                usercommand = cmd;
                tr = new TranslateAlloyToKodkod(rep2, opt, sigs, cmd);
                tr.makeFacts(cmd.formula);
                sim.totalOrderPredicates = tr.totalOrderPredicates;
                sol = tr.frame.solve(rep2, cmd, sim.partial == null || cmd.check ? new Simplifier() : sim, false);
                if (!sol.satisfiable() && !cmd.check) {
                    start = System.currentTimeMillis() - start;
                    if (sim.partial == null) {
                        rep.resultUNSAT(cmd, start, sol);
                        return sol;
                    } else {
                        rep.resultSAT(cmd, start, sim.partial);
                        return sim.partial;
                    }
                }
                if (sol.satisfiable() && cmd.check) {
                    start = System.currentTimeMillis() - start;
                    rep.resultSAT(cmd, start, sol);
                    return sol;
                }
                sim.partial = sol;
                if (sim.growableSigs.isEmpty())
                    break;
                for (Sig s : sim.growableSigs) {
                    CommandScope sc = cmd.getScope(s);
                    if (sc.increment > sc.endingScope - sc.startingScope) {
                        cmd = null;
                        break;
                    }
                    cmd = cmd.change(s, sc.isExact, sc.startingScope + sc.increment, sc.endingScope, sc.increment);
                }
            }
        }
        if (sol.satisfiable())
            rep.resultSAT(usercommand, System.currentTimeMillis() - start, sol);
        else
            rep.resultUNSAT(usercommand, System.currentTimeMillis() - start, sol);
        return sol;
    } catch (CapacityExceededException ex) {
        throw rethrow(ex);
    } catch (HigherOrderDeclException ex) {
        Pos p = tr != null ? tr.frame.kv2typepos(ex.decl().variable()).b : Pos.UNKNOWN;
        throw new ErrorType(p, "Analysis cannot be performed since it requires higher-order quantification that could not be skolemized.");
    }
}
Also used : A4Reporter(edu.mit.csail.sdg.alloy4.A4Reporter) ArrayList(java.util.ArrayList) Sig(edu.mit.csail.sdg.ast.Sig) CapacityExceededException(kodkod.engine.CapacityExceededException) ErrorType(edu.mit.csail.sdg.alloy4.ErrorType) Command(edu.mit.csail.sdg.ast.Command) Pos(edu.mit.csail.sdg.alloy4.Pos) HigherOrderDeclException(kodkod.engine.fol2sat.HigherOrderDeclException) CommandScope(edu.mit.csail.sdg.ast.CommandScope)

Example 9 with HigherOrderDeclException

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

the class TranslateAlloyToKodkod method alloy2kodkod.

/**
 * Translate the Alloy expression into an equivalent Kodkod Expression or
 * IntExpression or Formula object.
 *
 * @param sol - an existing satisfiable A4Solution object
 * @param expr - this is the Alloy expression we want to translate
 */
public static Object alloy2kodkod(A4Solution sol, Expr expr) throws Err {
    if (expr.ambiguous && !expr.errors.isEmpty())
        expr = expr.resolve(expr.type(), null);
    if (!expr.errors.isEmpty())
        throw expr.errors.pick();
    TranslateAlloyToKodkod tr = new TranslateAlloyToKodkod(sol.getBitwidth(), sol.unrolls(), sol.a2k(), sol.s2k());
    Object ans;
    try {
        ans = tr.visitThis(expr);
    } catch (UnsatisfiedLinkError ex) {
        throw new ErrorFatal("The required JNI library cannot be found: " + ex.toString().trim());
    } catch (CapacityExceededException ex) {
        throw rethrow(ex);
    } catch (HigherOrderDeclException ex) {
        throw new ErrorType("Analysis cannot be performed since it requires higher-order quantification that could not be skolemized.");
    } catch (Throwable ex) {
        if (ex instanceof Err)
            throw (Err) ex;
        throw new ErrorFatal("Unknown exception occurred: " + ex, ex);
    }
    if ((ans instanceof IntExpression) || (ans instanceof Formula) || (ans instanceof Expression))
        return ans;
    throw new ErrorFatal("Unknown internal error encountered in the evaluator.");
}
Also used : QuantifiedFormula(kodkod.ast.QuantifiedFormula) Formula(kodkod.ast.Formula) CapacityExceededException(kodkod.engine.CapacityExceededException) ErrorFatal(edu.mit.csail.sdg.alloy4.ErrorFatal) ErrorType(edu.mit.csail.sdg.alloy4.ErrorType) Err(edu.mit.csail.sdg.alloy4.Err) Expression(kodkod.ast.Expression) BinaryExpression(kodkod.ast.BinaryExpression) IntExpression(kodkod.ast.IntExpression) IntExpression(kodkod.ast.IntExpression) HigherOrderDeclException(kodkod.engine.fol2sat.HigherOrderDeclException)

Example 10 with HigherOrderDeclException

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

the class Trees method main.

/**
 * Usage: java examples.Trees [# vertices]
 */
public static void main(String[] args) {
    if (args.length < 1)
        usage();
    try {
        final int n = Integer.parseInt(args[0]);
        final Trees model = new Trees();
        final Bounds b = model.bounds(n);
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        solver.options().setBitwidth(16);
        // System.out.println(solver.solve(model.checkEquivOfTreeDefns(),
        // b));
        final Formula[] statements = new Formula[5];
        statements[0] = model.statement1();
        statements[1] = model.statement2();
        statements[2] = model.statement3();
        statements[3] = model.statement4();
        statements[4] = model.statement5();
        long time = 0;
        for (int i = 0; i < 5; i++) {
            Formula f = model.declsAndFacts().and(statements[i]).and(statements[(i + 1) % 5].not());
            Solution s = solver.solve(f, b);
            time += s.stats().translationTime() + s.stats().solvingTime();
            System.out.println(s);
            if (s.instance() != null) {
                return;
            }
        }
        System.out.println("valid: " + time + " ms");
    } 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)

Aggregations

HigherOrderDeclException (kodkod.engine.fol2sat.HigherOrderDeclException)12 Formula (kodkod.ast.Formula)8 Solution (kodkod.engine.Solution)7 Solver (kodkod.engine.Solver)7 UnboundLeafException (kodkod.engine.fol2sat.UnboundLeafException)7 Bounds (kodkod.instance.Bounds)7 ErrorType (edu.mit.csail.sdg.alloy4.ErrorType)4 CapacityExceededException (kodkod.engine.CapacityExceededException)4 Err (edu.mit.csail.sdg.alloy4.Err)3 ErrorFatal (edu.mit.csail.sdg.alloy4.ErrorFatal)3 Pos (edu.mit.csail.sdg.alloy4.Pos)3 ArrayList (java.util.ArrayList)3 Expression (kodkod.ast.Expression)2 IntExpression (kodkod.ast.IntExpression)2 QuantifiedFormula (kodkod.ast.QuantifiedFormula)2 Relation (kodkod.ast.Relation)2 TupleFactory (kodkod.instance.TupleFactory)2 Universe (kodkod.instance.Universe)2 A4Reporter (edu.mit.csail.sdg.alloy4.A4Reporter)1 Command (edu.mit.csail.sdg.ast.Command)1