// Constants definition // // Automaton definition // automaton evader contr_var: e, p, x, p_zero; // e position of the evader // p position of the pursuer // x timer // p_zero "frozen variable" that stores the // initial position of the pursuer synclabs: jump; loc ClkW: while 0 <= e <= 40 & 0 <= p <= 40 & x <= 2 wait {e'==5 & -0.5 <= p' <= 6 & x'==1 & p_zero'==0} when (p == 0) sync jump do {e'==e & p'==40 & x'==x & p_zero'==p_zero} goto ClkW; when (p == 40) sync jump do {e'==e & p'==0 & x'==x & p_zero'==p_zero} goto ClkW; when (x >= 2) & (0 < e < 40) & (6*e - 5*p > 40) sync jump do {e'==e & p'==p & x'==0 & p_zero'==p_zero} goto ClkW; when (x >= 2) & (0 < e < 40) & (6*e - 5*p <= 40) sync jump do {e'==e & p'==p & x'==0 & p_zero'==p_zero} goto CntrClkW; when (e == 0) sync jump do {e'==e & p'==p & x'==x & p_zero'==p_zero} goto Rescued; when (e == 40) sync jump do {e'==e & p'==p & x'==x & p_zero'==p_zero} goto Rescued; loc CntrClkW: while 0 <= e <= 40 & 0 <= p <= 40 & x <= 2 wait {e'==-5 & -0.5 <= p' <= 6 & x'==1 & p_zero'==0} when (p == 0) sync jump do {e'==e & p'==40 & x'==x & p_zero'==p_zero} goto CntrClkW; when (p == 40) sync jump do {e'==e & p'==0 & x'==x & p_zero'==p_zero} goto CntrClkW; when (x >= 2) & (0 < e < 40) & (6*e - 5*p > 40) sync jump do {e'==e & p'==p & x'==0 & p_zero'==p_zero} goto ClkW; when (x >= 2) & (0 < e < 40) & (6*e - 5*p <= 40) sync jump do {e'==e & p'==p & x'==0 & p_zero'==p_zero} goto CntrClkW; when (e == 0) sync jump do {e'==e & p'==p & x'==x & p_zero'==p_zero} goto Rescued; when (e == 40) sync jump do {e'==e & p'==p & x'==x & p_zero'==p_zero} goto Rescued; loc Rescued: while true wait {e'==0 & p'==0 & x'==0 & p_zero'==0}; initially: ClkW & x == 2 & e == 20 & p == p_zero & 0 <= p <= 40; end // Find winning starting points for pursuer // // Compute the reachable set // region=evader.reachable; // Intersect with states where pursuer wins forbidden = evader.{$ & e == p}; region.intersection_assign(forbidden); // Project on p_zero to get the initial position for the pursuer for which the // pursuer can win the game region.project_to(p_zero); // union over all locations pursuer_wins = region.loc_union; echo "The pursuer can win the game if it starts from:"; pursuer_wins.print;