// ----------------------------------------------------------------- // crab.txt: crab and racoon // Concrete Abstractions: Puzzles and Games // (c) 2020, Wolfgang Schreiner, RISC, JKU Linz, Austria // ----------------------------------------------------------------- // Problem 15.1 from Edwin F. Meier III et al: // Guide to Teaching Puzzle-Based Learning, Springer, 2014 // some crab burrows /* burrow 0 with holes 0 - 1 - 2 - 3 - 4 */ type Hole0 = ℕ[4]; val Move0 = { {0,1}, {1,2}, {2,3}, {3,4} }; /* burrow 1 with holes 0 - 1 - 2 - 3 - 4 | 5 | 6 */ type Hole1 = ℕ[6]; val Move1 = { {0,1}, {1,2}, {2,3}, {3,4}, {2,5}, {5,6} }; // the selected crab burrow type Hole = Hole1; val Move = Move1; // crab may move from hole i to hole j pred move(i:Hole,j:Hole) ⇔ {i,j} ∈ Move; // a system-based solution shared system CrabAndRaccoon { var holes:Set[Hole] = { h | h:Hole }; invariant holes ≠ ∅[Hole]; action look(h:Hole) with h∈holes; { holes ≔ { h1 | h1:Hole with ∃h0∈holes\{h}. move(h0,h1) }; } } // ----------------------------------------------------------------- // end of file // -----------------------------------------------------------------